Merge branch 'for-linus' into for-next
authorTakashi Iwai <tiwai@suse.de>
Fri, 25 Oct 2013 22:33:02 +0000 (00:33 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 25 Oct 2013 22:33:02 +0000 (00:33 +0200)
307 files changed:
Documentation/ABI/stable/sysfs-bus-usb
Documentation/ABI/testing/sysfs-devices-power
Documentation/ABI/testing/sysfs-power
Documentation/acpi/dsdt-override.txt
Documentation/devicetree/bindings/memory.txt [deleted file]
Documentation/devicetree/bindings/sound/cs42l73.txt [new file with mode: 0644]
Documentation/devicetree/bindings/sound/davinci-evm-audio.txt [new file with mode: 0644]
Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
Documentation/devicetree/bindings/sound/tlv320aic3x.txt
Documentation/devicetree/bindings/sound/tpa6130a2.txt [new file with mode: 0644]
Documentation/ioctl/ioctl-number.txt
Documentation/laptops/thinkpad-acpi.txt
Documentation/sound/alsa/soc/DPCM.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/codec.txt
Documentation/sound/alsa/soc/dapm.txt
Documentation/sound/alsa/soc/machine.txt
Documentation/sound/alsa/soc/platform.txt
MAINTAINERS
Makefile
arch/arm/common/mcpm_entry.c
arch/arm/common/sharpsl_param.c
arch/arm/include/asm/Kbuild
arch/arm/include/asm/mcpm.h
arch/arm/include/asm/syscall.h
arch/arm/kernel/head.S
arch/arm/mm/dma-mapping.c
arch/arm/mm/init.c
arch/x86/Kconfig
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/kernel/kvm.c
arch/x86/xen/smp.c
block/partitions/efi.c
drivers/acpi/Kconfig
drivers/acpi/device_pm.c
drivers/acpi/power.c
drivers/acpi/scan.c
drivers/ata/libata-acpi.c
drivers/ata/libata-scsi.c
drivers/ata/libata.h
drivers/base/memory.c
drivers/base/regmap/internal.h
drivers/base/regmap/regcache.c
drivers/base/regmap/regmap.c
drivers/char/tpm/xen-tpmfront.c
drivers/cpufreq/intel_pstate.c
drivers/cpufreq/s3c64xx-cpufreq.c
drivers/gpio/gpio-lynxpoint.c
drivers/gpio/gpiolib.c
drivers/iio/frequency/adf4350.c
drivers/iio/industrialio-buffer.c
drivers/infiniband/hw/amso1100/c2_ae.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mlx5/mr.c
drivers/infiniband/hw/mlx5/qp.c
drivers/infiniband/hw/mlx5/srq.c
drivers/infiniband/hw/mthca/mthca_eq.c
drivers/infiniband/hw/ocrdma/ocrdma_hw.c
drivers/infiniband/hw/ocrdma/ocrdma_main.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/md/dm-snap-persistent.c
drivers/mfd/mc13xxx-core.c
drivers/mfd/mc13xxx-spi.c
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
drivers/net/ethernet/mellanox/mlx5/core/eq.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
drivers/of/Kconfig
drivers/of/Makefile
drivers/of/base.c
drivers/of/fdt.c
drivers/of/of_reserved_mem.c [deleted file]
drivers/of/platform.c
drivers/pci/hotplug/acpiphp_glue.c
drivers/platform/x86/thinkpad_acpi.c
drivers/tty/serial/imx.c
drivers/tty/serial/vt8500_serial.c
drivers/usb/chipidea/host.c
drivers/usb/core/quirks.c
drivers/usb/host/pci-quirks.c
drivers/usb/host/xhci-hub.c
drivers/usb/host/xhci-pci.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h
drivers/usb/misc/Kconfig
drivers/usb/musb/musb_core.c
drivers/usb/musb/musb_core.h
drivers/usb/musb/musb_gadget.c
drivers/usb/musb/musb_virthub.c
drivers/usb/serial/option.c
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/storage/scsiglue.c
drivers/usb/storage/unusual_devs.h
drivers/vfio/vfio_iommu_type1.c
drivers/w1/w1.c
fs/btrfs/inode.c
fs/buffer.c
fs/cifs/cifsfs.c
fs/cifs/cifspdu.h
fs/cifs/cifssmb.c
fs/cifs/netmisc.c
fs/cifs/sess.c
fs/cifs/smb2pdu.c
fs/cifs/smbfsctl.h
fs/cifs/transport.c
fs/ext3/namei.c
fs/ext4/namei.c
fs/proc/inode.c
fs/proc/task_mmu.c
include/acpi/acpi_bus.h
include/linux/memcontrol.h
include/linux/mfd/mc13xxx.h
include/linux/mlx5/device.h
include/linux/mlx5/driver.h
include/linux/of_reserved_mem.h [deleted file]
include/linux/platform_data/davinci_asp.h
include/linux/regmap.h
include/linux/sched.h
include/linux/thinkpad_acpi.h [new file with mode: 0644]
include/linux/usb/usb_phy_gen_xceiv.h
include/linux/usb_usual.h
include/sound/compress_driver.h
include/sound/cs42l73.h [new file with mode: 0644]
include/sound/dmaengine_pcm.h
include/sound/memalloc.h
include/sound/rcar_snd.h
include/sound/soc-dai.h
include/sound/soc-dapm.h
include/sound/soc.h
include/trace/events/asoc.h
include/uapi/sound/Kbuild
include/uapi/sound/asound.h
include/uapi/sound/firewire.h [new file with mode: 0644]
ipc/sem.c
ipc/util.c
lib/percpu-refcount.c
mm/filemap.c
mm/huge_memory.c
mm/hugetlb.c
mm/memcontrol.c
mm/memory.c
mm/migrate.c
mm/mprotect.c
mm/mremap.c
mm/oom_kill.c
mm/page-writeback.c
mm/slab_common.c
mm/swapfile.c
mm/vmscan.c
mm/zswap.c
security/apparmor/apparmorfs.c
security/apparmor/policy.c
sound/arm/pxa2xx-ac97-lib.c
sound/core/compress_offload.c
sound/core/memalloc.c
sound/core/pcm_native.c
sound/firewire/Kconfig
sound/firewire/Makefile
sound/firewire/amdtp.c
sound/firewire/amdtp.h
sound/firewire/cmp.c
sound/firewire/dice-interface.h [new file with mode: 0644]
sound/firewire/dice.c [new file with mode: 0644]
sound/firewire/fcp.c
sound/firewire/isight.c
sound/firewire/lib.c
sound/firewire/lib.h
sound/firewire/scs1x.c
sound/firewire/speakers.c
sound/oss/sb_ess.c
sound/pci/asihpi/asihpi.c
sound/pci/au88x0/au88x0_pcm.c
sound/pci/au88x0/au88x0_synth.c
sound/pci/azt3328.c
sound/pci/ctxfi/ctdaio.c
sound/pci/emu10k1/emufx.c
sound/pci/hda/hda_beep.c
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/hda_eld.c
sound/pci/hda/hda_intel.c
sound/pci/hda/hda_local.h
sound/pci/hda/patch_ca0132.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_hdmi.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pci/rme9652/hdspm.c
sound/soc/Makefile
sound/soc/atmel/atmel-pcm.c
sound/soc/atmel/atmel_ssc_dai.c
sound/soc/atmel/atmel_wm8904.c
sound/soc/atmel/sam9g20_wm8731.c
sound/soc/cirrus/Kconfig
sound/soc/cirrus/ep93xx-pcm.c
sound/soc/codecs/88pm860x-codec.c
sound/soc/codecs/88pm860x-codec.h
sound/soc/codecs/ab8500-codec.c
sound/soc/codecs/adau1373.c
sound/soc/codecs/adav80x.c
sound/soc/codecs/ak4104.c
sound/soc/codecs/ak4641.c
sound/soc/codecs/ak4642.c
sound/soc/codecs/arizona.c
sound/soc/codecs/cq93vc.c
sound/soc/codecs/cs4271.c
sound/soc/codecs/cs42l73.c
sound/soc/codecs/cs42l73.h
sound/soc/codecs/max98088.c
sound/soc/codecs/max98095.c
sound/soc/codecs/max9850.c
sound/soc/codecs/mc13783.c
sound/soc/codecs/pcm1681.c
sound/soc/codecs/pcm1792a.c
sound/soc/codecs/rt5640.c
sound/soc/codecs/si476x.c
sound/soc/codecs/sn95031.c
sound/soc/codecs/tas5086.c
sound/soc/codecs/tlv320aic23.c
sound/soc/codecs/tlv320aic26.c
sound/soc/codecs/tlv320aic26.h
sound/soc/codecs/tlv320aic32x4.c
sound/soc/codecs/tlv320aic3x.c
sound/soc/codecs/tpa6130a2.c
sound/soc/codecs/twl4030.c
sound/soc/codecs/twl6040.c
sound/soc/codecs/wm8400.c
sound/soc/codecs/wm8962.c
sound/soc/davinci/Kconfig
sound/soc/davinci/Makefile
sound/soc/davinci/davinci-evm.c
sound/soc/davinci/davinci-mcasp.c
sound/soc/davinci/davinci-mcasp.h
sound/soc/fsl/fsl_spdif.c
sound/soc/fsl/fsl_ssi.c
sound/soc/fsl/imx-audmux.c
sound/soc/fsl/imx-mc13783.c
sound/soc/fsl/imx-pcm-dma.c
sound/soc/fsl/imx-sgtl5000.c
sound/soc/fsl/imx-spdif.c
sound/soc/fsl/imx-ssi.c
sound/soc/fsl/imx-wm8962.c
sound/soc/generic/simple-card.c
sound/soc/kirkwood/kirkwood-dma.c
sound/soc/kirkwood/kirkwood-i2s.c
sound/soc/kirkwood/kirkwood-openrd.c
sound/soc/kirkwood/kirkwood-t5325.c
sound/soc/kirkwood/kirkwood.h
sound/soc/mid-x86/mfld_machine.c
sound/soc/mxs/mxs-saif.c
sound/soc/mxs/mxs-saif.h
sound/soc/mxs/mxs-sgtl5000.c
sound/soc/omap/omap-mcpdm.c
sound/soc/omap/omap-twl4030.c
sound/soc/pxa/brownstone.c
sound/soc/pxa/corgi.c
sound/soc/pxa/e740_wm9705.c
sound/soc/pxa/e750_wm9705.c
sound/soc/pxa/e800_wm9712.c
sound/soc/pxa/imote2.c
sound/soc/pxa/mioa701_wm9713.c
sound/soc/pxa/mmp-sspa.c
sound/soc/pxa/palm27x.c
sound/soc/pxa/poodle.c
sound/soc/pxa/pxa2xx-ac97.c
sound/soc/pxa/tosa.c
sound/soc/pxa/ttc-dkb.c
sound/soc/samsung/bells.c
sound/soc/samsung/i2s.c
sound/soc/samsung/smdk_wm8994.c
sound/soc/sh/rcar/adg.c
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/gen.c
sound/soc/sh/rcar/rsnd.h
sound/soc/sh/rcar/scu.c
sound/soc/sh/rcar/ssi.c
sound/soc/soc-cache.c
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/soc-devres.c [new file with mode: 0644]
sound/soc/soc-generic-dmaengine-pcm.c
sound/soc/soc-io.c
sound/soc/soc-jack.c
sound/soc/soc-pcm.c
sound/soc/soc-utils.c
sound/soc/spear/spdif_in.c
sound/soc/spear/spdif_out.c
sound/soc/tegra/tegra20_i2s.c
sound/soc/tegra/tegra20_spdif.c
sound/soc/tegra/tegra30_ahub.c
sound/soc/tegra/tegra30_ahub.h
sound/soc/tegra/tegra30_i2s.c
sound/soc/tegra/tegra30_i2s.h
sound/soc/tegra/tegra_asoc_utils.c
sound/soc/tegra/tegra_asoc_utils.h
sound/soc/tegra/tegra_pcm.c
sound/usb/caiaq/control.c
sound/usb/caiaq/device.c
sound/usb/caiaq/device.h
sound/usb/card.c
sound/usb/card.h
sound/usb/endpoint.c
sound/usb/endpoint.h
sound/usb/helper.c
sound/usb/mixer.c
sound/usb/pcm.c
sound/usb/usbaudio.h
tools/testing/selftests/timers/posix_timers.c

index 2be603c52a240fa55f1a630d4f3567cc9c134d19..a6b68572474062bf04329a434cb27bbf825d19b8 100644 (file)
@@ -37,8 +37,8 @@ Description:
                that the USB device has been connected to the machine.  This
                file is read-only.
 Users:
-               PowerTOP <power@bughost.org>
-               http://www.lesswatts.org/projects/powertop/
+               PowerTOP <powertop@lists.01.org>
+               https://01.org/powertop/
 
 What:          /sys/bus/usb/device/.../power/active_duration
 Date:          January 2008
@@ -57,8 +57,8 @@ Description:
                will give an integer percentage.  Note that this does not
                account for counter wrap.
 Users:
-               PowerTOP <power@bughost.org>
-               http://www.lesswatts.org/projects/powertop/
+               PowerTOP <powertop@lists.01.org>
+               https://01.org/powertop/
 
 What:          /sys/bus/usb/devices/<busnum>-<port[.port]>...:<config num>-<interface num>/supports_autosuspend
 Date:          January 2008
index 9d43e76708413bdf6b3d25a0b1179714b06680ba..efe449bdf811db7a1c9f74f38a0371d2c0dd692e 100644 (file)
@@ -1,6 +1,6 @@
 What:          /sys/devices/.../power/
 Date:          January 2009
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../power directory contains attributes
                allowing the user space to check and modify some power
@@ -8,7 +8,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup
 Date:          January 2009
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../power/wakeup attribute allows the user
                space to check if the device is enabled to wake up the system
@@ -34,7 +34,7 @@ Description:
 
 What:          /sys/devices/.../power/control
 Date:          January 2009
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../power/control attribute allows the user
                space to control the run-time power management of the device.
@@ -53,7 +53,7 @@ Description:
 
 What:          /sys/devices/.../power/async
 Date:          January 2009
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../async attribute allows the user space to
                enable or diasble the device's suspend and resume callbacks to
@@ -79,7 +79,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_count
 Date:          September 2010
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_count attribute contains the number
                of signaled wakeup events associated with the device.  This
@@ -88,7 +88,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_active_count
 Date:          September 2010
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_active_count attribute contains the
                number of times the processing of wakeup events associated with
@@ -98,7 +98,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_abort_count
 Date:          February 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_abort_count attribute contains the
                number of times the processing of a wakeup event associated with
@@ -109,7 +109,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_expire_count
 Date:          February 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_expire_count attribute contains the
                number of times a wakeup event associated with the device has
@@ -119,7 +119,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_active
 Date:          September 2010
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_active attribute contains either 1,
                or 0, depending on whether or not a wakeup event associated with
@@ -129,7 +129,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_total_time_ms
 Date:          September 2010
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_total_time_ms attribute contains
                the total time of processing wakeup events associated with the
@@ -139,7 +139,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_max_time_ms
 Date:          September 2010
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_max_time_ms attribute contains
                the maximum time of processing a single wakeup event associated
@@ -149,7 +149,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_last_time_ms
 Date:          September 2010
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_last_time_ms attribute contains
                the value of the monotonic clock corresponding to the time of
@@ -160,7 +160,7 @@ Description:
 
 What:          /sys/devices/.../power/wakeup_prevent_sleep_time_ms
 Date:          February 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute
                contains the total time the device has been preventing
@@ -189,7 +189,7 @@ Description:
 
 What:          /sys/devices/.../power/pm_qos_latency_us
 Date:          March 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../power/pm_qos_resume_latency_us attribute
                contains the PM QoS resume latency limit for the given device,
@@ -207,7 +207,7 @@ Description:
 
 What:          /sys/devices/.../power/pm_qos_no_power_off
 Date:          September 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../power/pm_qos_no_power_off attribute
                is used for manipulating the PM QoS "no power off" flag.  If
@@ -222,7 +222,7 @@ Description:
 
 What:          /sys/devices/.../power/pm_qos_remote_wakeup
 Date:          September 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/devices/.../power/pm_qos_remote_wakeup attribute
                is used for manipulating the PM QoS "remote wakeup required"
index 217772615d0288f996e05cc128b98c9a40d95042..205a7387844106804de496ec9b3a8c372b725977 100644 (file)
@@ -1,6 +1,6 @@
 What:          /sys/power/
 Date:          August 2006
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power directory will contain files that will
                provide a unified interface to the power management
@@ -8,7 +8,7 @@ Description:
 
 What:          /sys/power/state
 Date:          August 2006
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/state file controls the system power state.
                Reading from this file returns what states are supported,
@@ -22,7 +22,7 @@ Description:
 
 What:          /sys/power/disk
 Date:          September 2006
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/disk file controls the operating mode of the
                suspend-to-disk mechanism.  Reading from this file returns
@@ -67,7 +67,7 @@ Description:
 
 What:          /sys/power/image_size
 Date:          August 2006
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/image_size file controls the size of the image
                created by the suspend-to-disk mechanism.  It can be written a
@@ -84,7 +84,7 @@ Description:
 
 What:          /sys/power/pm_trace
 Date:          August 2006
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/pm_trace file controls the code which saves the
                last PM event point in the RTC across reboots, so that you can
@@ -133,7 +133,7 @@ Description:
 
 What:          /sys/power/pm_async
 Date:          January 2009
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/pm_async file controls the switch allowing the
                user space to enable or disable asynchronous suspend and resume
@@ -146,7 +146,7 @@ Description:
 
 What:          /sys/power/wakeup_count
 Date:          July 2010
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/wakeup_count file allows user space to put the
                system into a sleep state while taking into account the
@@ -161,7 +161,7 @@ Description:
 
 What:          /sys/power/reserved_size
 Date:          May 2011
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/reserved_size file allows user space to control
                the amount of memory reserved for allocations made by device
@@ -175,7 +175,7 @@ Description:
 
 What:          /sys/power/autosleep
 Date:          April 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/autosleep file can be written one of the strings
                returned by reads from /sys/power/state.  If that happens, a
@@ -192,7 +192,7 @@ Description:
 
 What:          /sys/power/wake_lock
 Date:          February 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/wake_lock file allows user space to create
                wakeup source objects and activate them on demand (if one of
@@ -219,7 +219,7 @@ Description:
 
 What:          /sys/power/wake_unlock
 Date:          February 2012
-Contact:       Rafael J. Wysocki <rjw@sisk.pl>
+Contact:       Rafael J. Wysocki <rjw@rjwysocki.net>
 Description:
                The /sys/power/wake_unlock file allows user space to deactivate
                wakeup sources created with the help of /sys/power/wake_lock.
index febbb1ba4d2317b984e7217796ac39151f867531..784841caa6e63824ff2503351fb12e682f01e3b3 100644 (file)
@@ -4,4 +4,4 @@ CONFIG_ACPI_CUSTOM_DSDT builds the image into the kernel.
 
 When to use this method is described in detail on the
 Linux/ACPI home page:
-http://www.lesswatts.org/projects/acpi/overridingDSDT.php
+https://01.org/linux-acpi/documentation/overriding-dsdt
diff --git a/Documentation/devicetree/bindings/memory.txt b/Documentation/devicetree/bindings/memory.txt
deleted file mode 100644 (file)
index eb24693..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-*** Memory binding ***
-
-The /memory node provides basic information about the address and size
-of the physical memory. This node is usually filled or updated by the
-bootloader, depending on the actual memory configuration of the given
-hardware.
-
-The memory layout is described by the following node:
-
-/ {
-       #address-cells = <(n)>;
-       #size-cells = <(m)>;
-       memory {
-               device_type = "memory";
-               reg =  <(baseaddr1) (size1)
-                       (baseaddr2) (size2)
-                       ...
-                       (baseaddrN) (sizeN)>;
-       };
-       ...
-};
-
-A memory node follows the typical device tree rules for "reg" property:
-n:             number of cells used to store base address value
-m:             number of cells used to store size value
-baseaddrX:     defines a base address of the defined memory bank
-sizeX:         the size of the defined memory bank
-
-
-More than one memory bank can be defined.
-
-
-*** Reserved memory regions ***
-
-In /memory/reserved-memory node one can create child nodes describing
-particular reserved (excluded from normal use) memory regions. Such
-memory regions are usually designed for the special usage by various
-device drivers. A good example are contiguous memory allocations or
-memory sharing with other operating system on the same hardware board.
-Those special memory regions might depend on the board configuration and
-devices used on the target system.
-
-Parameters for each memory region can be encoded into the device tree
-with the following convention:
-
-[(label):] (name) {
-       compatible = "linux,contiguous-memory-region", "reserved-memory-region";
-       reg = <(address) (size)>;
-       (linux,default-contiguous-region);
-};
-
-compatible:    one or more of:
-       - "linux,contiguous-memory-region" - enables binding of this
-         region to Contiguous Memory Allocator (special region for
-         contiguous memory allocations, shared with movable system
-         memory, Linux kernel-specific).
-       - "reserved-memory-region" - compatibility is defined, given
-         region is assigned for exclusive usage for by the respective
-         devices.
-
-reg:   standard property defining the base address and size of
-       the memory region
-
-linux,default-contiguous-region: property indicating that the region
-       is the default region for all contiguous memory
-       allocations, Linux specific (optional)
-
-It is optional to specify the base address, so if one wants to use
-autoconfiguration of the base address, '0' can be specified as a base
-address in the 'reg' property.
-
-The /memory/reserved-memory node must contain the same #address-cells
-and #size-cells value as the root node.
-
-
-*** Device node's properties ***
-
-Once regions in the /memory/reserved-memory node have been defined, they
-may be referenced by other device nodes. Bindings that wish to reference
-memory regions should explicitly document their use of the following
-property:
-
-memory-region = <&phandle_to_defined_region>;
-
-This property indicates that the device driver should use the memory
-region pointed by the given phandle.
-
-
-*** Example ***
-
-This example defines a memory consisting of 4 memory banks. 3 contiguous
-regions are defined for Linux kernel, one default of all device drivers
-(named contig_mem, placed at 0x72000000, 64MiB), one dedicated to the
-framebuffer device (labelled display_mem, placed at 0x78000000, 8MiB)
-and one for multimedia processing (labelled multimedia_mem, placed at
-0x77000000, 64MiB). 'display_mem' region is then assigned to fb@12300000
-device for DMA memory allocations (Linux kernel drivers will use CMA is
-available or dma-exclusive usage otherwise). 'multimedia_mem' is
-assigned to scaler@12500000 and codec@12600000 devices for contiguous
-memory allocations when CMA driver is enabled.
-
-The reason for creating a separate region for framebuffer device is to
-match the framebuffer base address to the one configured by bootloader,
-so once Linux kernel drivers starts no glitches on the displayed boot
-logo appears. Scaller and codec drivers should share the memory
-allocations.
-
-/ {
-       #address-cells = <1>;
-       #size-cells = <1>;
-
-       /* ... */
-
-       memory {
-               reg =  <0x40000000 0x10000000
-                       0x50000000 0x10000000
-                       0x60000000 0x10000000
-                       0x70000000 0x10000000>;
-
-               reserved-memory {
-                       #address-cells = <1>;
-                       #size-cells = <1>;
-
-                       /*
-                        * global autoconfigured region for contiguous allocations
-                        * (used only with Contiguous Memory Allocator)
-                        */
-                       contig_region@0 {
-                               compatible = "linux,contiguous-memory-region";
-                               reg = <0x0 0x4000000>;
-                               linux,default-contiguous-region;
-                       };
-
-                       /*
-                        * special region for framebuffer
-                        */
-                       display_region: region@78000000 {
-                               compatible = "linux,contiguous-memory-region", "reserved-memory-region";
-                               reg = <0x78000000 0x800000>;
-                       };
-
-                       /*
-                        * special region for multimedia processing devices
-                        */
-                       multimedia_region: region@77000000 {
-                               compatible = "linux,contiguous-memory-region";
-                               reg = <0x77000000 0x4000000>;
-                       };
-               };
-       };
-
-       /* ... */
-
-       fb0: fb@12300000 {
-               status = "okay";
-               memory-region = <&display_region>;
-       };
-
-       scaler: scaler@12500000 {
-               status = "okay";
-               memory-region = <&multimedia_region>;
-       };
-
-       codec: codec@12600000 {
-               status = "okay";
-               memory-region = <&multimedia_region>;
-       };
-};
diff --git a/Documentation/devicetree/bindings/sound/cs42l73.txt b/Documentation/devicetree/bindings/sound/cs42l73.txt
new file mode 100644 (file)
index 0000000..80ae910
--- /dev/null
@@ -0,0 +1,22 @@
+CS42L73 audio CODEC
+
+Required properties:
+
+  - compatible : "cirrus,cs42l73"
+
+  - reg : the I2C address of the device for I2C
+
+Optional properties:
+
+  - reset_gpio : a GPIO spec for the reset pin.
+  - chgfreq    : Charge Pump Frequency values 0x00-0x0F
+
+
+Example:
+
+codec: cs42l73@4a {
+       compatible = "cirrus,cs42l73";
+       reg = <0x4a>;
+       reset_gpio = <&gpio 10 0>;
+       chgfreq = <0x05>;
+};
\ No newline at end of file
diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt
new file mode 100644 (file)
index 0000000..865178d
--- /dev/null
@@ -0,0 +1,42 @@
+* Texas Instruments SoC audio setups with TLV320AIC3X Codec
+
+Required properties:
+- compatible : "ti,da830-evm-audio" : forDM365/DA8xx/OMAPL1x/AM33xx
+- ti,model : The user-visible name of this sound complex.
+- ti,audio-codec : The phandle of the TLV320AIC3x audio codec
+- ti,mcasp-controller : The phandle of the McASP controller
+- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec
+- ti,audio-routing : A list of the connections between audio components.
+  Each entry is a pair of strings, the first being the connection's sink,
+  the second being the connection's source. Valid names for sources and
+  sinks are the codec's pins, and the jacks on the board:
+
+  Board connectors:
+
+  * Headphone Jack
+  * Line Out
+  * Mic Jack
+  * Line In
+
+
+Example:
+
+sound {
+       compatible = "ti,da830-evm-audio";
+       ti,model = "DA830 EVM";
+       ti,audio-codec = <&tlv320aic3x>;
+       ti,mcasp-controller = <&mcasp1>;
+       ti,codec-clock-rate = <12000000>;
+       ti,audio-routing =
+               "Headphone Jack",       "HPLOUT",
+               "Headphone Jack",       "HPROUT",
+               "Line Out",             "LLOUT",
+               "Line Out",             "RLOUT",
+               "MIC3L",                "Mic Bias 2V",
+               "MIC3R",                "Mic Bias 2V",
+               "Mic Bias 2V",          "Mic Jack",
+               "LINE1L",               "Line In",
+               "LINE2L",               "Line In",
+               "LINE1R",               "Line In",
+               "LINE2R",               "Line In";
+};
index 374e145c2ef170ceaa32055cf01836bfb3f8c3ef..ed785b3f67beacb6973ff1758b1b0d5b9b5f16dd 100644 (file)
@@ -4,17 +4,25 @@ Required properties:
 - compatible :
        "ti,dm646x-mcasp-audio" : for DM646x platforms
        "ti,da830-mcasp-audio"  : for both DA830 & DA850 platforms
-       "ti,omap2-mcasp-audio"  : for OMAP2 platforms (TI81xx, AM33xx)
-
-- reg : Should contain McASP registers offset and length
-- interrupts : Interrupt number for McASP
-- op-mode : I2S/DIT ops mode.
-- tdm-slots : Slots for TDM operation.
-- num-serializer : Serializers used by McASP.
-- serial-dir : A list of serializer pin mode. The list number should be equal
-               to "num-serializer" parameter. Each entry is a number indication
-               serializer pin direction. (0 - INACTIVE, 1 - TX, 2 - RX)
+       "ti,am33xx-mcasp-audio" : for AM33xx platforms (AM33xx, TI81xx)
 
+- reg : Should contain reg specifiers for the entries in the reg-names property.
+- reg-names : Should contain:
+         * "mpu" for the main registers (required). For compatibility with
+           existing software, it is recommended this is the first entry.
+         * "dat" for separate data port register access (optional).
+- op-mode : I2S/DIT ops mode. 0 for I2S mode. 1 for DIT mode used for S/PDIF,
+           IEC60958-1, and AES-3 formats.
+- tdm-slots : Slots for TDM operation. Indicates number of channels transmitted
+             or received over one serializer.
+- serial-dir : A list of serializer configuration. Each entry is a number
+               indication for serializer pin direction.
+               (0 - INACTIVE, 1 - TX, 2 - RX)
+- dmas: two element list of DMA controller phandles and DMA request line
+        ordered pairs.
+- dma-names: identifier string for each DMA request line in the dmas property.
+            These strings correspond 1:1 with the ordered pairs in dmas. The dma
+            identifiers must be "rx" and "tx".
 
 Optional properties:
 
@@ -23,18 +31,23 @@ Optional properties:
 - rx-num-evt : FIFO levels.
 - sram-size-playback : size of sram to be allocated during playback
 - sram-size-capture  : size of sram to be allocated during capture
+- interrupts : Interrupt numbers for McASP, currently not used by the driver
+- interrupt-names : Known interrupt names are "tx" and "rx"
+- pinctrl-0: Should specify pin control group used for this controller.
+- pinctrl-names: Should contain only one value - "default", for more details
+                please refer to pinctrl-bindings.txt
+  
 
 Example:
 
 mcasp0: mcasp0@1d00000 {
        compatible = "ti,da830-mcasp-audio";
-       #address-cells = <1>;
-       #size-cells = <0>;
        reg = <0x100000 0x3000>;
-       interrupts = <82 83>;
+       reg-names "mpu";
+       interrupts = <82>, <83>;
+       interrupts-names = "tx", "rx";
        op-mode = <0>;          /* MCASP_IIS_MODE */
        tdm-slots = <2>;
-       num-serializer = <16>;
        serial-dir = <
                        0 0 0 0 /* 0: INACTIVE, 1: TX, 2: RX */
                        0 0 0 0
index 705a6b156c6c4fc00713443f5fa631996b259401..5e6040c2c2e9c34019dceb93e439504e4e5af9ad 100644 (file)
@@ -24,10 +24,36 @@ Optional properties:
        3 - MICBIAS output is connected to AVDD,
        If this node is not mentioned or if the value is incorrect, then MicBias
        is powered down.
+- AVDD-supply, IOVDD-supply, DRVDD-supply, DVDD-supply : power supplies for the
+  device as covered in Documentation/devicetree/bindings/regulator/regulator.txt
+
+CODEC output pins:
+  * LLOUT
+  * RLOUT
+  * MONO_LOUT
+  * HPLOUT
+  * HPROUT
+  * HPLCOM
+  * HPRCOM
+
+CODEC input pins:
+  * MIC3L
+  * MIC3R
+  * LINE1L
+  * LINE2L
+  * LINE1R
+  * LINE2R
+
+The pins can be used in referring sound node's audio-routing property.
 
 Example:
 
 tlv320aic3x: tlv320aic3x@1b {
        compatible = "ti,tlv320aic3x";
        reg = <0x1b>;
+
+       AVDD-supply = <&regulator>;
+       IOVDD-supply = <&regulator>;
+       DRVDD-supply = <&regulator>;
+       DVDD-supply = <&regulator>;
 };
diff --git a/Documentation/devicetree/bindings/sound/tpa6130a2.txt b/Documentation/devicetree/bindings/sound/tpa6130a2.txt
new file mode 100644 (file)
index 0000000..6dfa740
--- /dev/null
@@ -0,0 +1,27 @@
+Texas Instruments - tpa6130a2 Codec module
+
+The tpa6130a2 serial control bus communicates through I2C protocols
+
+Required properties:
+
+- compatible - "string" - One of:
+    "ti,tpa6130a2" - TPA6130A2
+    "ti,tpa6140a2" - TPA6140A2
+
+
+- reg - <int> -  I2C slave address
+
+- Vdd-supply - <phandle> - power supply regulator
+
+Optional properties:
+
+- power-gpio - gpio pin to power the device
+
+Example:
+
+tpa6130a2: tpa6130a2@60 {
+       compatible = "ti,tpa6130a2";
+       reg = <0x60>;
+       Vdd-supply = <&vmmc2>;
+       power-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>;
+};
index 2a5f0e14efa351a73ef1eb53c392ecef7c9b4f6b..7cbfa3c4fc3d327c8b1d9c3ef8a4c1228998a69b 100644 (file)
@@ -138,6 +138,7 @@ Code  Seq#(hex)     Include File            Comments
 'H'    C0-DF   net/bluetooth/cmtp/cmtp.h       conflict!
 'H'    C0-DF   net/bluetooth/bnep/bnep.h       conflict!
 'H'    F1      linux/hid-roccat.h      <mailto:erazor_de@users.sourceforge.net>
+'H'    F8-FA   sound/firewire.h
 'I'    all     linux/isdn.h            conflict!
 'I'    00-0F   drivers/isdn/divert/isdn_divert.h       conflict!
 'I'    40-4F   linux/mISDNif.h         conflict!
index 86c52360ffe7326cce53541897d4aa98b86f0e8a..fc04c14de4bbc3705e14eddb97a214ca8a7f6331 100644 (file)
@@ -1,7 +1,7 @@
                     ThinkPad ACPI Extras Driver
 
-                            Version 0.24
-                        December 11th,  2009
+                            Version 0.25
+                        October 16th,  2013
 
                Borislav Deianov <borislav@users.sf.net>
              Henrique de Moraes Holschuh <hmh@hmh.eng.br>
@@ -741,6 +741,9 @@ compiled with the CONFIG_THINKPAD_ACPI_UNSAFE_LEDS option enabled.
 Distributions must never enable this option.  Individual users that
 are aware of the consequences are welcome to enabling it.
 
+Audio mute and microphone mute LEDs are supported, but currently not
+visible to userspace. They are used by the snd-hda-intel audio driver.
+
 procfs notes:
 
 The available commands are:
diff --git a/Documentation/sound/alsa/soc/DPCM.txt b/Documentation/sound/alsa/soc/DPCM.txt
new file mode 100644 (file)
index 0000000..aa8546f
--- /dev/null
@@ -0,0 +1,380 @@
+Dynamic PCM
+===========
+
+1. Description
+==============
+
+Dynamic PCM allows an ALSA PCM device to digitally route its PCM audio to
+various digital endpoints during the PCM stream runtime. e.g. PCM0 can route
+digital audio to I2S DAI0, I2S DAI1 or PDM DAI2. This is useful for on SoC DSP
+drivers that expose several ALSA PCMs and can route to multiple DAIs.
+
+The DPCM runtime routing is determined by the ALSA mixer settings in the same
+way as the analog signal is routed in an ASoC codec driver. DPCM uses a DAPM
+graph representing the DSP internal audio paths and uses the mixer settings to
+determine the patch used by each ALSA PCM.
+
+DPCM re-uses all the existing component codec, platform and DAI drivers without
+any modifications.
+
+
+Phone Audio System with SoC based DSP
+-------------------------------------
+
+Consider the following phone audio subsystem. This will be used in this
+document for all examples :-
+
+| Front End PCMs    |  SoC DSP  | Back End DAIs | Audio devices |
+
+                    *************
+PCM0 <------------> *           * <----DAI0-----> Codec Headset
+                    *           *
+PCM1 <------------> *           * <----DAI1-----> Codec Speakers
+                    *   DSP     *
+PCM2 <------------> *           * <----DAI2-----> MODEM
+                    *           *
+PCM3 <------------> *           * <----DAI3-----> BT
+                    *           *
+                    *           * <----DAI4-----> DMIC
+                    *           *
+                    *           * <----DAI5-----> FM
+                    *************
+
+This diagram shows a simple smart phone audio subsystem. It supports Bluetooth,
+FM digital radio, Speakers, Headset Jack, digital microphones and cellular
+modem. This sound card exposes 4 DSP front end (FE) ALSA PCM devices and
+supports 6 back end (BE) DAIs. Each FE PCM can digitally route audio data to any
+of the BE DAIs. The FE PCM devices can also route audio to more than 1 BE DAI.
+
+
+
+Example - DPCM Switching playback from DAI0 to DAI1
+---------------------------------------------------
+
+Audio is being played to the Headset. After a while the user removes the headset
+and audio continues playing on the speakers.
+
+Playback on PCM0 to Headset would look like :-
+
+                    *************
+PCM0 <============> *           * <====DAI0=====> Codec Headset
+                    *           *
+PCM1 <------------> *           * <----DAI1-----> Codec Speakers
+                    *   DSP     *
+PCM2 <------------> *           * <----DAI2-----> MODEM
+                    *           *
+PCM3 <------------> *           * <----DAI3-----> BT
+                    *           *
+                    *           * <----DAI4-----> DMIC
+                    *           *
+                    *           * <----DAI5-----> FM
+                    *************
+
+The headset is removed from the jack by user so the speakers must now be used :-
+
+                    *************
+PCM0 <============> *           * <----DAI0-----> Codec Headset
+                    *           *
+PCM1 <------------> *           * <====DAI1=====> Codec Speakers
+                    *   DSP     *
+PCM2 <------------> *           * <----DAI2-----> MODEM
+                    *           *
+PCM3 <------------> *           * <----DAI3-----> BT
+                    *           *
+                    *           * <----DAI4-----> DMIC
+                    *           *
+                    *           * <----DAI5-----> FM
+                    *************
+
+The audio driver processes this as follows :-
+
+ 1) Machine driver receives Jack removal event.
+
+ 2) Machine driver OR audio HAL disables the Headset path.
+
+ 3) DPCM runs the PCM trigger(stop), hw_free(), shutdown() operations on DAI0
+    for headset since the path is now disabled.
+
+ 4) Machine driver or audio HAL enables the speaker path.
+
+ 5) DPCM runs the PCM ops for startup(), hw_params(), prepapre() and
+    trigger(start) for DAI1 Speakers since the path is enabled.
+
+In this example, the machine driver or userspace audio HAL can alter the routing
+and then DPCM will take care of managing the DAI PCM operations to either bring
+the link up or down. Audio playback does not stop during this transition.
+
+
+
+DPCM machine driver
+===================
+
+The DPCM enabled ASoC machine driver is similar to normal machine drivers
+except that we also have to :-
+
+ 1) Define the FE and BE DAI links.
+
+ 2) Define any FE/BE PCM operations.
+
+ 3) Define widget graph connections.
+
+
+1 FE and BE DAI links
+---------------------
+
+| Front End PCMs    |  SoC DSP  | Back End DAIs | Audio devices |
+
+                    *************
+PCM0 <------------> *           * <----DAI0-----> Codec Headset
+                    *           *
+PCM1 <------------> *           * <----DAI1-----> Codec Speakers
+                    *   DSP     *
+PCM2 <------------> *           * <----DAI2-----> MODEM
+                    *           *
+PCM3 <------------> *           * <----DAI3-----> BT
+                    *           *
+                    *           * <----DAI4-----> DMIC
+                    *           *
+                    *           * <----DAI5-----> FM
+                    *************
+
+For the example above we have to define 4 FE DAI links and 6 BE DAI links. The
+FE DAI links are defined as follows :-
+
+static struct snd_soc_dai_link machine_dais[] = {
+       {
+               .name = "PCM0 System",
+               .stream_name = "System Playback",
+               .cpu_dai_name = "System Pin",
+               .platform_name = "dsp-audio",
+               .codec_name = "snd-soc-dummy",
+               .codec_dai_name = "snd-soc-dummy-dai",
+               .dynamic = 1,
+               .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
+               .dpcm_playback = 1,
+       },
+       .....< other FE and BE DAI links here >
+};
+
+This FE DAI link is pretty similar to a regular DAI link except that we also
+set the DAI link to a DPCM FE with the "dynamic = 1". The supported FE stream
+directions should also be set with the "dpcm_playback" and "dpcm_capture"
+flags. There is also an option to specify the ordering of the trigger call for
+each FE. This allows the ASoC core to trigger the DSP before or after the other
+components (as some DSPs have strong requirements for the ordering DAI/DSP
+start and stop sequences).
+
+The FE DAI above sets the codec and code DAIs to dummy devices since the BE is
+dynamic and will change depending on runtime config.
+
+The BE DAIs are configured as follows :-
+
+static struct snd_soc_dai_link machine_dais[] = {
+       .....< FE DAI links here >
+       {
+               .name = "Codec Headset",
+               .cpu_dai_name = "ssp-dai.0",
+               .platform_name = "snd-soc-dummy",
+               .no_pcm = 1,
+               .codec_name = "rt5640.0-001c",
+               .codec_dai_name = "rt5640-aif1",
+               .ignore_suspend = 1,
+               .ignore_pmdown_time = 1,
+               .be_hw_params_fixup = hswult_ssp0_fixup,
+               .ops = &haswell_ops,
+               .dpcm_playback = 1,
+               .dpcm_capture = 1,
+       },
+       .....< other BE DAI links here >
+};
+
+This BE DAI link connects DAI0 to the codec (in this case RT5460 AIF1). It sets
+the "no_pcm" flag to mark it has a BE and sets flags for supported stream
+directions using "dpcm_playback" and "dpcm_capture" above.
+
+The BE has also flags set for ignoreing suspend and PM down time. This allows
+the BE to work in a hostless mode where the host CPU is not transferring data
+like a BT phone call :-
+
+                    *************
+PCM0 <------------> *           * <----DAI0-----> Codec Headset
+                    *           *
+PCM1 <------------> *           * <----DAI1-----> Codec Speakers
+                    *   DSP     *
+PCM2 <------------> *           * <====DAI2=====> MODEM
+                    *           *
+PCM3 <------------> *           * <====DAI3=====> BT
+                    *           *
+                    *           * <----DAI4-----> DMIC
+                    *           *
+                    *           * <----DAI5-----> FM
+                    *************
+
+This allows the host CPU to sleep whilst the DSP, MODEM DAI and the BT DAI are
+still in operation.
+
+A BE DAI link can also set the codec to a dummy device if the code is a device
+that is managed externally.
+
+Likewise a BE DAI can also set a dummy cpu DAI if the CPU DAI is managed by the
+DSP firmware.
+
+
+2 FE/BE PCM operations
+----------------------
+
+The BE above also exports some PCM operations and a "fixup" callback. The fixup
+callback is used by the machine driver to (re)configure the DAI based upon the
+FE hw params. i.e. the DSP may perform SRC or ASRC from the FE to BE.
+
+e.g. DSP converts all FE hw params to run at fixed rate of 48k, 16bit, stereo for
+DAI0. This means all FE hw_params have to be fixed in the machine driver for
+DAI0 so that the DAI is running at desired configuration regardless of the FE
+configuration.
+
+static int dai0_fixup(struct snd_soc_pcm_runtime *rtd,
+                       struct snd_pcm_hw_params *params)
+{
+       struct snd_interval *rate = hw_param_interval(params,
+                       SNDRV_PCM_HW_PARAM_RATE);
+       struct snd_interval *channels = hw_param_interval(params,
+                                               SNDRV_PCM_HW_PARAM_CHANNELS);
+
+       /* The DSP will covert the FE rate to 48k, stereo */
+       rate->min = rate->max = 48000;
+       channels->min = channels->max = 2;
+
+       /* set DAI0 to 16 bit */
+       snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
+                                   SNDRV_PCM_HW_PARAM_FIRST_MASK],
+                                   SNDRV_PCM_FORMAT_S16_LE);
+       return 0;
+}
+
+The other PCM operation are the same as for regular DAI links. Use as necessary.
+
+
+3 Widget graph connections
+--------------------------
+
+The BE DAI links will normally be connected to the graph at initialisation time
+by the ASoC DAPM core. However, if the BE codec or BE DAI is a dummy then this
+has to be set explicitly in the driver :-
+
+/* BE for codec Headset -  DAI0 is dummy and managed by DSP FW */
+{"DAI0 CODEC IN", NULL, "AIF1 Capture"},
+{"AIF1 Playback", NULL, "DAI0 CODEC OUT"},
+
+
+Writing a DPCM DSP driver
+=========================
+
+The DPCM DSP driver looks much like a standard platform class ASoC driver
+combined with elements from a codec class driver. A DSP platform driver must
+implement :-
+
+ 1) Front End PCM DAIs - i.e. struct snd_soc_dai_driver.
+
+ 2) DAPM graph showing DSP audio routing from FE DAIs to BEs.
+
+ 3) DAPM widgets from DSP graph.
+
+ 4) Mixers for gains, routing, etc.
+
+ 5) DMA configuration.
+
+ 6) BE AIF widgets.
+
+Items 6 is important for routing the audio outside of the DSP. AIF need to be
+defined for each BE and each stream direction. e.g for BE DAI0 above we would
+have :-
+
+SND_SOC_DAPM_AIF_IN("DAI0 RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+SND_SOC_DAPM_AIF_OUT("DAI0 TX", NULL, 0, SND_SOC_NOPM, 0, 0),
+
+The BE AIF are used to connect the DSP graph to the graphs for the other
+component drivers (e.g. codec graph).
+
+
+Hostless PCM streams
+====================
+
+A hostless PCM stream is a stream that is not routed through the host CPU. An
+example of this would be a phone call from handset to modem.
+
+
+                    *************
+PCM0 <------------> *           * <----DAI0-----> Codec Headset
+                    *           *
+PCM1 <------------> *           * <====DAI1=====> Codec Speakers/Mic
+                    *   DSP     *
+PCM2 <------------> *           * <====DAI2=====> MODEM
+                    *           *
+PCM3 <------------> *           * <----DAI3-----> BT
+                    *           *
+                    *           * <----DAI4-----> DMIC
+                    *           *
+                    *           * <----DAI5-----> FM
+                    *************
+
+In this case the PCM data is routed via the DSP. The host CPU in this use case
+is only used for control and can sleep during the runtime of the stream.
+
+The host can control the hostless link either by :-
+
+ 1) Configuring the link as a CODEC <-> CODEC style link. In this case the link
+    is enabled or disabled by the state of the DAPM graph. This usually means
+    there is a mixer control that can be used to connect or disconnect the path
+    between both DAIs.
+
+ 2) Hostless FE. This FE has a virtual connection to the BE DAI links on the DAPM
+    graph. Control is then carried out by the FE as regualar PCM operations.
+    This method gives more control over the DAI links, but requires much more
+    userspace code to control the link. Its recommended to use CODEC<->CODEC
+    unless your HW needs more fine grained sequencing of the PCM ops.
+
+
+CODEC <-> CODEC link
+--------------------
+
+This DAI link is enabled when DAPM detects a valid path within the DAPM graph.
+The machine driver sets some additional parameters to the DAI link i.e.
+
+static const struct snd_soc_pcm_stream dai_params = {
+       .formats = SNDRV_PCM_FMTBIT_S32_LE,
+       .rate_min = 8000,
+       .rate_max = 8000,
+       .channels_min = 2,
+       .channels_max = 2,
+};
+
+static struct snd_soc_dai_link dais[] = {
+       < ... more DAI links above ... >
+       {
+               .name = "MODEM",
+               .stream_name = "MODEM",
+               .cpu_dai_name = "dai2",
+               .codec_dai_name = "modem-aif1",
+               .codec_name = "modem",
+               .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
+                               | SND_SOC_DAIFMT_CBM_CFM,
+               .params = &dai_params,
+       }
+       < ... more DAI links here ... >
+
+These parameters are used to configure the DAI hw_params() when DAPM detects a
+valid path and then calls the PCM operations to start the link. DAPM will also
+call the appropriate PCM operations to disable the DAI when the path is no
+longer valid.
+
+
+Hostless FE
+-----------
+
+The DAI link(s) are enabled by a FE that does not read or write any PCM data.
+This means creating a new FE that is connected with a virtual path to both
+DAI links. The DAI links will be started when the FE PCM is started and stopped
+when the FE PCM is stopped. Note that the FE PCM cannot read or write data in
+this configuration.
+
+
index bce23a4a78750c630becfc9f6cf9e109ed6721c7..db5f9c9ae1495186e4439705d59f24ea3ce04b49 100644 (file)
@@ -1,22 +1,23 @@
-ASoC Codec Driver
-=================
+ASoC Codec Class Driver
+=======================
 
-The codec driver is generic and hardware independent code that configures the
-codec to provide audio capture and playback. It should contain no code that is
-specific to the target platform or machine. All platform and machine specific
-code should be added to the platform and machine drivers respectively.
+The codec class driver is generic and hardware independent code that configures
+the codec, FM, MODEM, BT or external DSP to provide audio capture and playback.
+It should contain no code that is specific to the target platform or machine.
+All platform and machine specific code should be added to the platform and
+machine drivers respectively.
 
-Each codec driver *must* provide the following features:-
+Each codec class driver *must* provide the following features:-
 
  1) Codec DAI and PCM configuration
- 2) Codec control IO - using I2C, 3 Wire(SPI) or both APIs
+ 2) Codec control IO - using RegMap API
  3) Mixers and audio controls
  4) Codec audio operations
+ 5) DAPM description.
+ 6) DAPM event handler.
 
 Optionally, codec drivers can also provide:-
 
- 5) DAPM description.
- 6) DAPM event handler.
  7) DAC Digital mute control.
 
 Its probably best to use this guide in conjunction with the existing codec
@@ -64,26 +65,9 @@ struct snd_soc_dai_driver wm8731_dai = {
 2 - Codec control IO
 --------------------
 The codec can usually be controlled via an I2C or SPI style interface
-(AC97 combines control with data in the DAI). The codec drivers provide
-functions to read and write the codec registers along with supplying a
-register cache:-
-
-       /* IO control data and register cache */
-       void *control_data; /* codec control (i2c/3wire) data */
-       void *reg_cache;
-
-Codec read/write should do any data formatting and call the hardware
-read write below to perform the IO. These functions are called by the
-core and ALSA when performing DAPM or changing the mixer:-
-
-    unsigned int (*read)(struct snd_soc_codec *, unsigned int);
-    int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
-
-Codec hardware IO functions - usually points to either the I2C, SPI or AC97
-read/write:-
-
-       hw_write_t hw_write;
-       hw_read_t hw_read;
+(AC97 combines control with data in the DAI). The codec driver should use the
+Regmap API for all codec IO. Please see include/linux/regmap.h and existing
+codec drivers for example regmap usage.
 
 
 3 - Mixers and audio controls
@@ -127,7 +111,7 @@ Defines a stereo enumerated control
 
 4 - Codec Audio Operations
 --------------------------
-The codec driver also supports the following ALSA operations:-
+The codec driver also supports the following ALSA PCM operations:-
 
 /* SoC audio ops */
 struct snd_soc_ops {
index 05bf5a0eee415b8ad29a25a61d90b54e145d9096..7dfd88ce31ac195633b89d728e0dc7787a2f41bf 100644 (file)
@@ -21,7 +21,7 @@ level power systems.
 
 There are 4 power domains within DAPM
 
-   1. Codec domain - VREF, VMID (core codec and audio power)
+   1. Codec bias domain - VREF, VMID (core codec and audio power)
       Usually controlled at codec probe/remove and suspend/resume, although
       can be set at stream time if power is not needed for sidetone, etc.
 
@@ -63,14 +63,22 @@ Audio DAPM widgets fall into a number of types:-
  o Line       - Line Input/Output (and optional Jack)
  o Speaker    - Speaker
  o Supply     - Power or clock supply widget used by other widgets.
+ o Regulator  - External regulator that supplies power to audio components.
+ o Clock      -        External clock that supplies clock to audio componnents.
+ o AIF IN     - Audio Interface Input (with TDM slot mask).
+ o AIF OUT    - Audio Interface Output (with TDM slot mask).
+ o Siggen     - Signal Generator.
+ o DAI IN     - Digital Audio Interface Input.
+ o DAI OUT    - Digital Audio Interface Output.
+ o DAI Link   - DAI Link between two DAI structures */
  o Pre        - Special PRE widget (exec before all others)
  o Post       - Special POST widget (exec after all others)
 
 (Widgets are defined in include/sound/soc-dapm.h)
 
-Widgets are usually added in the codec driver and the machine driver. There are
-convenience macros defined in soc-dapm.h that can be used to quickly build a
-list of widgets of the codecs and machines DAPM widgets.
+Widgets can be added to the sound card by any of the component driver types.
+There are convenience macros defined in soc-dapm.h that can be used to quickly
+build a list of widgets of the codecs and machines DAPM widgets.
 
 Most widgets have a name, register, shift and invert. Some widgets have extra
 parameters for stream name and kcontrols.
@@ -80,11 +88,13 @@ parameters for stream name and kcontrols.
 -------------------------
 
 Stream Widgets relate to the stream power domain and only consist of ADCs
-(analog to digital converters) and DACs (digital to analog converters).
+(analog to digital converters), DACs (digital to analog converters),
+AIF IN and AIF OUT.
 
 Stream widgets have the following format:-
 
 SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert),
+SND_SOC_DAPM_AIF_IN(name, stream, slot, reg, shift, invert)
 
 NOTE: the stream name must match the corresponding stream name in your codec
 snd_soc_codec_dai.
@@ -94,6 +104,11 @@ e.g. stream widgets for HiFi playback and capture
 SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1),
 SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1),
 
+e.g. stream widgets for AIF
+
+SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
+SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
+
 
 2.2 Path Domain Widgets
 -----------------------
@@ -121,12 +136,14 @@ If you dont want the mixer elements prefixed with the name of the mixer widget,
 you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same
 as for SND_SOC_DAPM_MIXER.
 
-2.3 Platform/Machine domain Widgets
------------------------------------
+
+2.3 Machine domain Widgets
+--------------------------
 
 Machine widgets are different from codec widgets in that they don't have a
 codec register bit associated with them. A machine widget is assigned to each
-machine audio component (non codec) that can be independently powered. e.g.
+machine audio component (non codec or DSP) that can be independently
+powered. e.g.
 
  o Speaker Amp
  o Microphone Bias
@@ -146,12 +163,12 @@ static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event)
 SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias),
 
 
-2.4 Codec Domain
-----------------
+2.4 Codec (BIAS) Domain
+-----------------------
 
-The codec power domain has no widgets and is handled by the codecs DAPM event
-handler. This handler is called when the codec powerstate is changed wrt to any
-stream event or by kernel PM events.
+The codec bias power domain has no widgets and is handled by the codecs DAPM
+event handler. This handler is called when the codec powerstate is changed wrt
+to any stream event or by kernel PM events.
 
 
 2.5 Virtual Widgets
@@ -169,15 +186,16 @@ After all the widgets have been defined, they can then be added to the DAPM
 subsystem individually with a call to snd_soc_dapm_new_control().
 
 
-3. Codec Widget Interconnections
-================================
+3. Codec/DSP Widget Interconnections
+====================================
 
-Widgets are connected to each other within the codec and machine by audio paths
-(called interconnections). Each interconnection must be defined in order to
-create a map of all audio paths between widgets.
+Widgets are connected to each other within the codec, platform and machine by
+audio paths (called interconnections). Each interconnection must be defined in
+order to create a map of all audio paths between widgets.
 
-This is easiest with a diagram of the codec (and schematic of the machine audio
-system), as it requires joining widgets together via their audio signal paths.
+This is easiest with a diagram of the codec or DSP (and schematic of the machine
+audio system), as it requires joining widgets together via their audio signal
+paths.
 
 e.g., from the WM8731 output mixer (wm8731.c)
 
@@ -247,16 +265,9 @@ machine and includes the codec. e.g.
  o Mic Jack
  o Codec Pins
 
-When a codec pin is NC it can be marked as not used with a call to
-
-snd_soc_dapm_set_endpoint(codec, "Widget Name", 0);
-
-The last argument is 0 for inactive and 1 for active. This way the pin and its
-input widget will never be powered up and consume power.
-
-This also applies to machine widgets. e.g. if a headphone is connected to a
-jack then the jack can be marked active. If the headphone is removed, then
-the headphone jack can be marked inactive.
+Endpoints are added to the DAPM graph so that their usage can be determined in
+order to save power. e.g. NC codecs pins will be switched OFF, unconnected
+jacks can also be switched OFF.
 
 
 5 DAPM Widget Events
index d50c14df34112ed2095942062bcaab90d90697bd..74056dba52be7aab7adbcadd45064fa71d79534f 100644 (file)
@@ -1,8 +1,10 @@
 ASoC Machine Driver
 ===================
 
-The ASoC machine (or board) driver is the code that glues together the platform
-and codec drivers.
+The ASoC machine (or board) driver is the code that glues together all the
+component drivers (e.g. codecs, platforms and DAIs). It also describes the
+relationships between each componnent which include audio paths, GPIOs,
+interrupts, clocking, jacks and voltage regulators.
 
 The machine driver can contain codec and platform specific code. It registers
 the audio subsystem with the kernel as a platform device and is represented by
index d57efad37e0a5b33606599f6735f180706fd228d..3a08a2c9150c991ec6ff9be44633d592578f0b94 100644 (file)
@@ -1,9 +1,9 @@
 ASoC Platform Driver
 ====================
 
-An ASoC platform driver can be divided into audio DMA and SoC DAI configuration
-and control. The platform drivers only target the SoC CPU and must have no board
-specific code.
+An ASoC platform driver class can be divided into audio DMA drivers, SoC DAI
+drivers and DSP drivers. The platform drivers only target the SoC CPU and must
+have no board specific code.
 
 Audio DMA
 =========
@@ -64,3 +64,16 @@ Each SoC DAI driver must provide the following features:-
  5) Suspend and resume (optional)
 
 Please see codec.txt for a description of items 1 - 4.
+
+
+SoC DSP Drivers
+===============
+
+Each SoC DSP driver usually supplies the following features :-
+
+ 1) DAPM graph
+ 2) Mixer controls
+ 3) DMA IO to/from DSP buffers (if applicable)
+ 4) Definition of DSP front end (FE) PCM devices.
+
+Please see DPCM.txt for a description of item 4.
index a30a8143330ce6ae38df4337ca309b079228a41f..90b4fe3aca5380027e98d3cfebf8b453d10f0fc5 100644 (file)
@@ -237,11 +237,11 @@ F:        drivers/platform/x86/acer-wmi.c
 
 ACPI
 M:     Len Brown <lenb@kernel.org>
-M:     Rafael J. Wysocki <rjw@sisk.pl>
+M:     Rafael J. Wysocki <rjw@rjwysocki.net>
 L:     linux-acpi@vger.kernel.org
-W:     http://www.lesswatts.org/projects/acpi/
-Q:     http://patchwork.kernel.org/project/linux-acpi/list/
-T:     git git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
+W:     https://01.org/linux-acpi
+Q:     https://patchwork.kernel.org/project/linux-acpi/list/
+T:     git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
 S:     Supported
 F:     drivers/acpi/
 F:     drivers/pnp/pnpacpi/
@@ -256,21 +256,21 @@ F:        drivers/pci/*/*/*acpi*
 ACPI FAN DRIVER
 M:     Zhang Rui <rui.zhang@intel.com>
 L:     linux-acpi@vger.kernel.org
-W:     http://www.lesswatts.org/projects/acpi/
+W:     https://01.org/linux-acpi
 S:     Supported
 F:     drivers/acpi/fan.c
 
 ACPI THERMAL DRIVER
 M:     Zhang Rui <rui.zhang@intel.com>
 L:     linux-acpi@vger.kernel.org
-W:     http://www.lesswatts.org/projects/acpi/
+W:     https://01.org/linux-acpi
 S:     Supported
 F:     drivers/acpi/*thermal*
 
 ACPI VIDEO DRIVER
 M:     Zhang Rui <rui.zhang@intel.com>
 L:     linux-acpi@vger.kernel.org
-W:     http://www.lesswatts.org/projects/acpi/
+W:     https://01.org/linux-acpi
 S:     Supported
 F:     drivers/acpi/video.c
 
@@ -2300,7 +2300,7 @@ S:        Maintained
 F:     drivers/net/ethernet/ti/cpmac.c
 
 CPU FREQUENCY DRIVERS
-M:     Rafael J. Wysocki <rjw@sisk.pl>
+M:     Rafael J. Wysocki <rjw@rjwysocki.net>
 M:     Viresh Kumar <viresh.kumar@linaro.org>
 L:     cpufreq@vger.kernel.org
 L:     linux-pm@vger.kernel.org
@@ -2331,7 +2331,7 @@ S:      Maintained
 F:      drivers/cpuidle/cpuidle-big_little.c
 
 CPUIDLE DRIVERS
-M:     Rafael J. Wysocki <rjw@sisk.pl>
+M:     Rafael J. Wysocki <rjw@rjwysocki.net>
 M:     Daniel Lezcano <daniel.lezcano@linaro.org>
 L:     linux-pm@vger.kernel.org
 S:     Maintained
@@ -3553,7 +3553,7 @@ F:        fs/freevxfs/
 
 FREEZER
 M:     Pavel Machek <pavel@ucw.cz>
-M:     "Rafael J. Wysocki" <rjw@sisk.pl>
+M:     "Rafael J. Wysocki" <rjw@rjwysocki.net>
 L:     linux-pm@vger.kernel.org
 S:     Supported
 F:     Documentation/power/freezing-of-tasks.txt
@@ -3624,6 +3624,12 @@ L:       linux-scsi@vger.kernel.org
 S:     Odd Fixes (e.g., new signatures)
 F:     drivers/scsi/fdomain.*
 
+GCOV BASED KERNEL PROFILING
+M:     Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
+S:     Maintained
+F:     kernel/gcov/
+F:     Documentation/gcov.txt
+
 GDT SCSI DISK ARRAY CONTROLLER DRIVER
 M:     Achim Leubner <achim_leubner@adaptec.com>
 L:     linux-scsi@vger.kernel.org
@@ -3889,7 +3895,7 @@ F:        drivers/video/hgafb.c
 
 HIBERNATION (aka Software Suspend, aka swsusp)
 M:     Pavel Machek <pavel@ucw.cz>
-M:     "Rafael J. Wysocki" <rjw@sisk.pl>
+M:     "Rafael J. Wysocki" <rjw@rjwysocki.net>
 L:     linux-pm@vger.kernel.org
 S:     Supported
 F:     arch/x86/power/
@@ -4339,7 +4345,7 @@ F:        drivers/video/i810/
 INTEL MENLOW THERMAL DRIVER
 M:     Sujith Thomas <sujith.thomas@intel.com>
 L:     platform-driver-x86@vger.kernel.org
-W:     http://www.lesswatts.org/projects/acpi/
+W:     https://01.org/linux-acpi
 S:     Supported
 F:     drivers/platform/x86/intel_menlow.c
 
@@ -8102,7 +8108,7 @@ F:        drivers/sh/
 SUSPEND TO RAM
 M:     Len Brown <len.brown@intel.com>
 M:     Pavel Machek <pavel@ucw.cz>
-M:     "Rafael J. Wysocki" <rjw@sisk.pl>
+M:     "Rafael J. Wysocki" <rjw@rjwysocki.net>
 L:     linux-pm@vger.kernel.org
 S:     Supported
 F:     Documentation/power/
index deec08b7612b4c0d903ca6c9323eddaac6e4ea08..126321d2e6ad6a3c594280ca1102e0b25c7e4dd3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 3
 PATCHLEVEL = 12
 SUBLEVEL = 0
-EXTRAVERSION = -rc5
+EXTRAVERSION = -rc6
 NAME = One Giant Leap for Frogkind
 
 # *DOCUMENTATION*
index 370236dd1a03309ee3b123e705aa80132c908427..990250965f2cfb4e4e3a984678fcf62eedbcdb8d 100644 (file)
@@ -51,7 +51,8 @@ void mcpm_cpu_power_down(void)
 {
        phys_reset_t phys_reset;
 
-       BUG_ON(!platform_ops);
+       if (WARN_ON_ONCE(!platform_ops || !platform_ops->power_down))
+               return;
        BUG_ON(!irqs_disabled());
 
        /*
@@ -93,7 +94,8 @@ void mcpm_cpu_suspend(u64 expected_residency)
 {
        phys_reset_t phys_reset;
 
-       BUG_ON(!platform_ops);
+       if (WARN_ON_ONCE(!platform_ops || !platform_ops->suspend))
+               return;
        BUG_ON(!irqs_disabled());
 
        /* Very similar to mcpm_cpu_power_down() */
index d56c932580eb201439c8a63aa401abddd157cbbf..025f6ce38596736eea2c929a211b23fd4eaf0d56 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/string.h>
 #include <asm/mach/sharpsl_param.h>
+#include <asm/memory.h>
 
 /*
  * Certain hardware parameters determined at the time of device manufacture,
  */
 #ifdef CONFIG_ARCH_SA1100
 #define PARAM_BASE     0xe8ffc000
+#define param_start(x) (void *)(x)
 #else
 #define PARAM_BASE     0xa0000a00
+#define param_start(x) __va(x)
 #endif
 #define MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 )  | ( b << 8 ) | a )
 
@@ -41,7 +44,7 @@ EXPORT_SYMBOL(sharpsl_param);
 
 void sharpsl_save_param(void)
 {
-       memcpy(&sharpsl_param, (void *)PARAM_BASE, sizeof(struct sharpsl_param_info));
+       memcpy(&sharpsl_param, param_start(PARAM_BASE), sizeof(struct sharpsl_param_info));
 
        if (sharpsl_param.comadj_keyword != COMADJ_MAGIC)
                sharpsl_param.comadj=-1;
index d3db39860b9cc5eb83053f99f9430b926443609c..59ceae8f3c959616851a21ba3f08ae18941146ca 100644 (file)
@@ -31,5 +31,4 @@ generic-y += termbits.h
 generic-y += termios.h
 generic-y += timex.h
 generic-y += trace_clock.h
-generic-y += types.h
 generic-y += unaligned.h
index 0f7b7620e9a554b0b4a0ba4939a60c905e0a435c..fc82a88f5b69e556e9235583364b5149b2572b66 100644 (file)
@@ -76,8 +76,11 @@ int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster);
  *
  * This must be called with interrupts disabled.
  *
- * This does not return.  Re-entry in the kernel is expected via
- * mcpm_entry_point.
+ * On success this does not return.  Re-entry in the kernel is expected
+ * via mcpm_entry_point.
+ *
+ * This will return if mcpm_platform_register() has not been called
+ * previously in which case the caller should take appropriate action.
  */
 void mcpm_cpu_power_down(void);
 
@@ -98,8 +101,11 @@ void mcpm_cpu_power_down(void);
  *
  * This must be called with interrupts disabled.
  *
- * This does not return.  Re-entry in the kernel is expected via
- * mcpm_entry_point.
+ * On success this does not return.  Re-entry in the kernel is expected
+ * via mcpm_entry_point.
+ *
+ * This will return if mcpm_platform_register() has not been called
+ * previously in which case the caller should take appropriate action.
  */
 void mcpm_cpu_suspend(u64 expected_residency);
 
index f1d96d4e8092a652aeb84f5825082a8f9064cd20..73ddd7239b33aa77d178ae1341c0c46c736a08e5 100644 (file)
@@ -57,6 +57,9 @@ static inline void syscall_get_arguments(struct task_struct *task,
                                         unsigned int i, unsigned int n,
                                         unsigned long *args)
 {
+       if (n == 0)
+               return;
+
        if (i + n > SYSCALL_MAX_ARGS) {
                unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
                unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
@@ -81,6 +84,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
                                         unsigned int i, unsigned int n,
                                         const unsigned long *args)
 {
+       if (n == 0)
+               return;
+
        if (i + n > SYSCALL_MAX_ARGS) {
                pr_warning("%s called with max args %d, handling only %d\n",
                           __func__, i + n, SYSCALL_MAX_ARGS);
index 2c7cc1e03473aee9463e86d7dbedfc999f6e51f7..476de57dcef284602e126e29e2da03465df8ff09 100644 (file)
@@ -487,7 +487,26 @@ __fixup_smp:
        mrc     p15, 0, r0, c0, c0, 5   @ read MPIDR
        and     r0, r0, #0xc0000000     @ multiprocessing extensions and
        teq     r0, #0x80000000         @ not part of a uniprocessor system?
-       moveq   pc, lr                  @ yes, assume SMP
+       bne    __fixup_smp_on_up        @ no, assume UP
+
+       @ Core indicates it is SMP. Check for Aegis SOC where a single
+       @ Cortex-A9 CPU is present but SMP operations fault.
+       mov     r4, #0x41000000
+       orr     r4, r4, #0x0000c000
+       orr     r4, r4, #0x00000090
+       teq     r3, r4                  @ Check for ARM Cortex-A9
+       movne   pc, lr                  @ Not ARM Cortex-A9,
+
+       @ If a future SoC *does* use 0x0 as the PERIPH_BASE, then the
+       @ below address check will need to be #ifdef'd or equivalent
+       @ for the Aegis platform.
+       mrc     p15, 4, r0, c15, c0     @ get SCU base address
+       teq     r0, #0x0                @ '0' on actual UP A9 hardware
+       beq     __fixup_smp_on_up       @ So its an A9 UP
+       ldr     r0, [r0, #4]            @ read SCU Config
+       and     r0, r0, #0x3            @ number of CPUs
+       teq     r0, #0x0                @ is 1?
+       movne   pc, lr
 
 __fixup_smp_on_up:
        adr     r0, 1f
index f5e1a8471714cd421e2ab9dee54ae88f144316d1..1272ed202ddee97c2a9143d97afbf4bed69f0fea 100644 (file)
@@ -1232,7 +1232,8 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size)
                                break;
 
                len = (j - i) << PAGE_SHIFT;
-               ret = iommu_map(mapping->domain, iova, phys, len, 0);
+               ret = iommu_map(mapping->domain, iova, phys, len,
+                               IOMMU_READ|IOMMU_WRITE);
                if (ret < 0)
                        goto fail;
                iova += len;
@@ -1431,6 +1432,27 @@ static int arm_iommu_get_sgtable(struct device *dev, struct sg_table *sgt,
                                         GFP_KERNEL);
 }
 
+static int __dma_direction_to_prot(enum dma_data_direction dir)
+{
+       int prot;
+
+       switch (dir) {
+       case DMA_BIDIRECTIONAL:
+               prot = IOMMU_READ | IOMMU_WRITE;
+               break;
+       case DMA_TO_DEVICE:
+               prot = IOMMU_READ;
+               break;
+       case DMA_FROM_DEVICE:
+               prot = IOMMU_WRITE;
+               break;
+       default:
+               prot = 0;
+       }
+
+       return prot;
+}
+
 /*
  * Map a part of the scatter-gather list into contiguous io address space
  */
@@ -1444,6 +1466,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
        int ret = 0;
        unsigned int count;
        struct scatterlist *s;
+       int prot;
 
        size = PAGE_ALIGN(size);
        *handle = DMA_ERROR_CODE;
@@ -1460,7 +1483,9 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
                        !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
                        __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir);
 
-               ret = iommu_map(mapping->domain, iova, phys, len, 0);
+               prot = __dma_direction_to_prot(dir);
+
+               ret = iommu_map(mapping->domain, iova, phys, len, prot);
                if (ret < 0)
                        goto fail;
                count += len >> PAGE_SHIFT;
@@ -1665,19 +1690,7 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p
        if (dma_addr == DMA_ERROR_CODE)
                return dma_addr;
 
-       switch (dir) {
-       case DMA_BIDIRECTIONAL:
-               prot = IOMMU_READ | IOMMU_WRITE;
-               break;
-       case DMA_TO_DEVICE:
-               prot = IOMMU_READ;
-               break;
-       case DMA_FROM_DEVICE:
-               prot = IOMMU_WRITE;
-               break;
-       default:
-               prot = 0;
-       }
+       prot = __dma_direction_to_prot(dir);
 
        ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot);
        if (ret < 0)
index febaee7ca57be76487290a2ac45c6cf74e53759c..18ec4c504abf908ac9ddca01a4458a8183c6cc95 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/nodemask.h>
 #include <linux/initrd.h>
 #include <linux/of_fdt.h>
-#include <linux/of_reserved_mem.h>
 #include <linux/highmem.h>
 #include <linux/gfp.h>
 #include <linux/memblock.h>
@@ -379,8 +378,6 @@ void __init arm_memblock_init(struct meminfo *mi,
        if (mdesc->reserve)
                mdesc->reserve();
 
-       early_init_dt_scan_reserved_mem();
-
        /*
         * reserve memory for DMA contigouos allocations,
         * must come from DMA area inside low memory
index 145d703227bf63542560df60a842d2b8aa0f1f7c..f67e839f06c845e406d81c8b2be285ced8b57448 100644 (file)
@@ -1033,6 +1033,7 @@ config X86_REBOOTFIXUPS
 
 config MICROCODE
        tristate "CPU microcode loading support"
+       depends on CPU_SUP_AMD || CPU_SUP_INTEL
        select FW_LOADER
        ---help---
 
index 1191ac1c9d2598e64d13a1419b4a7a383933ce03..a419814cea575f9e2cf183772a9e99c59e097a11 100644 (file)
@@ -113,7 +113,7 @@ static int __init early_get_pnodeid(void)
                break;
        case UV3_HUB_PART_NUMBER:
        case UV3_HUB_PART_NUMBER_X:
-               uv_min_hub_revision_id += UV3_HUB_REVISION_BASE - 1;
+               uv_min_hub_revision_id += UV3_HUB_REVISION_BASE;
                break;
        }
 
index 697b93af02ddbc0fb4461b5d853810fa250cd0a1..a0e2a8a80c94129bb3d3d47bf975ef68f98f500e 100644 (file)
@@ -775,11 +775,22 @@ void __init kvm_spinlock_init(void)
        if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
                return;
 
-       printk(KERN_INFO "KVM setup paravirtual spinlock\n");
+       pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning);
+       pv_lock_ops.unlock_kick = kvm_unlock_kick;
+}
+
+static __init int kvm_spinlock_init_jump(void)
+{
+       if (!kvm_para_available())
+               return 0;
+       if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
+               return 0;
 
        static_key_slow_inc(&paravirt_ticketlocks_enabled);
+       printk(KERN_INFO "KVM setup paravirtual spinlock\n");
 
-       pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning);
-       pv_lock_ops.unlock_kick = kvm_unlock_kick;
+       return 0;
 }
+early_initcall(kvm_spinlock_init_jump);
+
 #endif /* CONFIG_PARAVIRT_SPINLOCKS */
index d1e4777b4e75352fea33ca6a3e3d43a679e19c6d..31d04758b76f6a2da41c309e368768d4881066d0 100644 (file)
@@ -278,6 +278,15 @@ static void __init xen_smp_prepare_boot_cpu(void)
                   old memory can be recycled */
                make_lowmem_page_readwrite(xen_initial_gdt);
 
+#ifdef CONFIG_X86_32
+               /*
+                * Xen starts us with XEN_FLAT_RING1_DS, but linux code
+                * expects __USER_DS
+                */
+               loadsegment(ds, __USER_DS);
+               loadsegment(es, __USER_DS);
+#endif
+
                xen_filter_cpu_maps();
                xen_setup_vcpu_info_placement();
        }
index 1eb09ee5311b414e448b28eb26a72f7ff6bbaa1c..a8287b49d0621d1778295ad0516c8ccbf22ed0fa 100644 (file)
@@ -222,11 +222,16 @@ check_hybrid:
         * the disk size.
         *
         * Hybrid MBRs do not necessarily comply with this.
+        *
+        * Consider a bad value here to be a warning to support dd'ing
+        * an image from a smaller disk to a larger disk.
         */
        if (ret == GPT_MBR_PROTECTIVE) {
                sz = le32_to_cpu(mbr->partition_record[part].size_in_lba);
                if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF)
-                       ret = 0;
+                       pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n",
+                                sz, min_t(uint32_t,
+                                          total_sectors - 1, 0xFFFFFFFF));
        }
 done:
        return ret;
index 22327e6a7236fc367313ec5acf45016d354863d4..6efe2ac6902fa635bf90a2d3e3d14728949aad5c 100644 (file)
@@ -24,7 +24,7 @@ menuconfig ACPI
          are configured, ACPI is used.
 
          The project home page for the Linux ACPI subsystem is here:
-         <http://www.lesswatts.org/projects/acpi/>
+         <https://01.org/linux-acpi>
 
          Linux support for ACPI is based on Intel Corporation's ACPI
          Component Architecture (ACPI CA).  For more information on the
@@ -123,9 +123,9 @@ config ACPI_BUTTON
        default y
        help
          This driver handles events on the power, sleep, and lid buttons.
-         A daemon reads /proc/acpi/event and perform user-defined actions
-         such as shutting down the system.  This is necessary for
-         software-controlled poweroff.
+         A daemon reads events from input devices or via netlink and
+         performs user-defined actions such as shutting down the system.
+         This is necessary for software-controlled poweroff.
 
          To compile this driver as a module, choose M here:
          the module will be called button.
index 59d3202f6b36fc197afe259b343764cb2a9621aa..a94383d1f3502ae35138e7e677df02c1d8df3d72 100644 (file)
@@ -1025,60 +1025,4 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off)
        }
 }
 EXPORT_SYMBOL_GPL(acpi_dev_pm_detach);
-
-/**
- * acpi_dev_pm_add_dependent - Add physical device depending for PM.
- * @handle: Handle of ACPI device node.
- * @depdev: Device depending on that node for PM.
- */
-void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev)
-{
-       struct acpi_device_physical_node *dep;
-       struct acpi_device *adev;
-
-       if (!depdev || acpi_bus_get_device(handle, &adev))
-               return;
-
-       mutex_lock(&adev->physical_node_lock);
-
-       list_for_each_entry(dep, &adev->power_dependent, node)
-               if (dep->dev == depdev)
-                       goto out;
-
-       dep = kzalloc(sizeof(*dep), GFP_KERNEL);
-       if (dep) {
-               dep->dev = depdev;
-               list_add_tail(&dep->node, &adev->power_dependent);
-       }
-
- out:
-       mutex_unlock(&adev->physical_node_lock);
-}
-EXPORT_SYMBOL_GPL(acpi_dev_pm_add_dependent);
-
-/**
- * acpi_dev_pm_remove_dependent - Remove physical device depending for PM.
- * @handle: Handle of ACPI device node.
- * @depdev: Device depending on that node for PM.
- */
-void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev)
-{
-       struct acpi_device_physical_node *dep;
-       struct acpi_device *adev;
-
-       if (!depdev || acpi_bus_get_device(handle, &adev))
-               return;
-
-       mutex_lock(&adev->physical_node_lock);
-
-       list_for_each_entry(dep, &adev->power_dependent, node)
-               if (dep->dev == depdev) {
-                       list_del(&dep->node);
-                       kfree(dep);
-                       break;
-               }
-
-       mutex_unlock(&adev->physical_node_lock);
-}
-EXPORT_SYMBOL_GPL(acpi_dev_pm_remove_dependent);
 #endif /* CONFIG_PM */
index 0dbe5cdf3396e5f53b23c84bb30041329544774d..c2ad391d8041ecb6a354e2df07b9d813d817a744 100644 (file)
@@ -59,16 +59,9 @@ ACPI_MODULE_NAME("power");
 #define ACPI_POWER_RESOURCE_STATE_ON   0x01
 #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF
 
-struct acpi_power_dependent_device {
-       struct list_head node;
-       struct acpi_device *adev;
-       struct work_struct work;
-};
-
 struct acpi_power_resource {
        struct acpi_device device;
        struct list_head list_node;
-       struct list_head dependent;
        char *name;
        u32 system_level;
        u32 order;
@@ -233,32 +226,6 @@ static int acpi_power_get_list_state(struct list_head *list, int *state)
        return 0;
 }
 
-static void acpi_power_resume_dependent(struct work_struct *work)
-{
-       struct acpi_power_dependent_device *dep;
-       struct acpi_device_physical_node *pn;
-       struct acpi_device *adev;
-       int state;
-
-       dep = container_of(work, struct acpi_power_dependent_device, work);
-       adev = dep->adev;
-       if (acpi_power_get_inferred_state(adev, &state))
-               return;
-
-       if (state > ACPI_STATE_D0)
-               return;
-
-       mutex_lock(&adev->physical_node_lock);
-
-       list_for_each_entry(pn, &adev->physical_node_list, node)
-               pm_request_resume(pn->dev);
-
-       list_for_each_entry(pn, &adev->power_dependent, node)
-               pm_request_resume(pn->dev);
-
-       mutex_unlock(&adev->physical_node_lock);
-}
-
 static int __acpi_power_on(struct acpi_power_resource *resource)
 {
        acpi_status status = AE_OK;
@@ -283,14 +250,8 @@ static int acpi_power_on_unlocked(struct acpi_power_resource *resource)
                                  resource->name));
        } else {
                result = __acpi_power_on(resource);
-               if (result) {
+               if (result)
                        resource->ref_count--;
-               } else {
-                       struct acpi_power_dependent_device *dep;
-
-                       list_for_each_entry(dep, &resource->dependent, node)
-                               schedule_work(&dep->work);
-               }
        }
        return result;
 }
@@ -390,52 +351,6 @@ static int acpi_power_on_list(struct list_head *list)
        return result;
 }
 
-static void acpi_power_add_dependent(struct acpi_power_resource *resource,
-                                    struct acpi_device *adev)
-{
-       struct acpi_power_dependent_device *dep;
-
-       mutex_lock(&resource->resource_lock);
-
-       list_for_each_entry(dep, &resource->dependent, node)
-               if (dep->adev == adev)
-                       goto out;
-
-       dep = kzalloc(sizeof(*dep), GFP_KERNEL);
-       if (!dep)
-               goto out;
-
-       dep->adev = adev;
-       INIT_WORK(&dep->work, acpi_power_resume_dependent);
-       list_add_tail(&dep->node, &resource->dependent);
-
- out:
-       mutex_unlock(&resource->resource_lock);
-}
-
-static void acpi_power_remove_dependent(struct acpi_power_resource *resource,
-                                       struct acpi_device *adev)
-{
-       struct acpi_power_dependent_device *dep;
-       struct work_struct *work = NULL;
-
-       mutex_lock(&resource->resource_lock);
-
-       list_for_each_entry(dep, &resource->dependent, node)
-               if (dep->adev == adev) {
-                       list_del(&dep->node);
-                       work = &dep->work;
-                       break;
-               }
-
-       mutex_unlock(&resource->resource_lock);
-
-       if (work) {
-               cancel_work_sync(work);
-               kfree(dep);
-       }
-}
-
 static struct attribute *attrs[] = {
        NULL,
 };
@@ -524,8 +439,6 @@ static void acpi_power_expose_hide(struct acpi_device *adev,
 
 void acpi_power_add_remove_device(struct acpi_device *adev, bool add)
 {
-       struct acpi_device_power_state *ps;
-       struct acpi_power_resource_entry *entry;
        int state;
 
        if (adev->wakeup.flags.valid)
@@ -535,16 +448,6 @@ void acpi_power_add_remove_device(struct acpi_device *adev, bool add)
        if (!adev->power.flags.power_resources)
                return;
 
-       ps = &adev->power.states[ACPI_STATE_D0];
-       list_for_each_entry(entry, &ps->resources, node) {
-               struct acpi_power_resource *resource = entry->resource;
-
-               if (add)
-                       acpi_power_add_dependent(resource, adev);
-               else
-                       acpi_power_remove_dependent(resource, adev);
-       }
-
        for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++)
                acpi_power_expose_hide(adev,
                                       &adev->power.states[state].resources,
@@ -882,7 +785,6 @@ int acpi_add_power_resource(acpi_handle handle)
        acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER,
                                ACPI_STA_DEFAULT);
        mutex_init(&resource->resource_lock);
-       INIT_LIST_HEAD(&resource->dependent);
        INIT_LIST_HEAD(&resource->list_node);
        resource->name = device->pnp.bus_id;
        strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
@@ -936,8 +838,10 @@ void acpi_resume_power_resources(void)
                mutex_lock(&resource->resource_lock);
 
                result = acpi_power_get_state(resource->device.handle, &state);
-               if (result)
+               if (result) {
+                       mutex_unlock(&resource->resource_lock);
                        continue;
+               }
 
                if (state == ACPI_POWER_RESOURCE_STATE_OFF
                    && resource->ref_count) {
index 407ad13cac2f27945c3b812f791a4f615c2db492..fee8a297c7d95310caa64492b75e6c2fae0c280e 100644 (file)
@@ -999,7 +999,6 @@ int acpi_device_add(struct acpi_device *device,
        INIT_LIST_HEAD(&device->wakeup_list);
        INIT_LIST_HEAD(&device->physical_node_list);
        mutex_init(&device->physical_node_lock);
-       INIT_LIST_HEAD(&device->power_dependent);
 
        new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
        if (!new_bus_id) {
index 4ba8b04055728d49a0ac147a608d1ad27391d62a..ab714d2ad978644752ca3c9bdff74ae1c9f63934 100644 (file)
@@ -1035,17 +1035,3 @@ void ata_acpi_on_disable(struct ata_device *dev)
 {
        ata_acpi_clear_gtf(dev);
 }
-
-void ata_scsi_acpi_bind(struct ata_device *dev)
-{
-       acpi_handle handle = ata_dev_acpi_handle(dev);
-       if (handle)
-               acpi_dev_pm_add_dependent(handle, &dev->sdev->sdev_gendev);
-}
-
-void ata_scsi_acpi_unbind(struct ata_device *dev)
-{
-       acpi_handle handle = ata_dev_acpi_handle(dev);
-       if (handle)
-               acpi_dev_pm_remove_dependent(handle, &dev->sdev->sdev_gendev);
-}
index 97a0cef1295916223202058b83e80a20de74c7de..db6dfcfa3e2ee932190069290814f2a71bc8f3f6 100644 (file)
@@ -3679,7 +3679,6 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
                        if (!IS_ERR(sdev)) {
                                dev->sdev = sdev;
                                scsi_device_put(sdev);
-                               ata_scsi_acpi_bind(dev);
                        } else {
                                dev->sdev = NULL;
                        }
@@ -3767,8 +3766,6 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
        struct scsi_device *sdev;
        unsigned long flags;
 
-       ata_scsi_acpi_unbind(dev);
-
        /* Alas, we need to grab scan_mutex to ensure SCSI device
         * state doesn't change underneath us and thus
         * scsi_device_get() always succeeds.  The mutex locking can
index eeeb77845d48574e3f43b4b6e456302e5f3926d9..45b5ab3a95d51158c9ef0e618d6c8ae0fdeb373b 100644 (file)
@@ -121,8 +121,6 @@ extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state);
 extern void ata_acpi_bind_port(struct ata_port *ap);
 extern void ata_acpi_bind_dev(struct ata_device *dev);
 extern acpi_handle ata_dev_acpi_handle(struct ata_device *dev);
-extern void ata_scsi_acpi_bind(struct ata_device *dev);
-extern void ata_scsi_acpi_unbind(struct ata_device *dev);
 #else
 static inline void ata_acpi_dissociate(struct ata_host *host) { }
 static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; }
@@ -133,8 +131,6 @@ static inline void ata_acpi_set_state(struct ata_port *ap,
                                      pm_message_t state) { }
 static inline void ata_acpi_bind_port(struct ata_port *ap) {}
 static inline void ata_acpi_bind_dev(struct ata_device *dev) {}
-static inline void ata_scsi_acpi_bind(struct ata_device *dev) {}
-static inline void ata_scsi_acpi_unbind(struct ata_device *dev) {}
 #endif
 
 /* libata-scsi.c */
index 9e59f6535c442bbb26d6ad055b93a4b0cf5bef5d..bece691cb5d99d79f761b9400eebf1e9a78c55a2 100644 (file)
@@ -333,8 +333,10 @@ store_mem_state(struct device *dev,
                online_type = ONLINE_KEEP;
        else if (!strncmp(buf, "offline", min_t(int, count, 7)))
                online_type = -1;
-       else
-               return -EINVAL;
+       else {
+               ret = -EINVAL;
+               goto err;
+       }
 
        switch (online_type) {
        case ONLINE_KERNEL:
@@ -357,6 +359,7 @@ store_mem_state(struct device *dev,
                ret = -EINVAL; /* should never happen */
        }
 
+err:
        unlock_device_hotplug();
 
        if (ret)
index 57f777835d97d852ef9067970c8bec276ea6e8ae..33414b1de2013b8e3fc68f31a70f8a56f2900cbe 100644 (file)
@@ -44,7 +44,6 @@ struct regmap_format {
 
 struct regmap_async {
        struct list_head list;
-       struct work_struct cleanup;
        struct regmap *map;
        void *work_buf;
 };
@@ -64,9 +63,11 @@ struct regmap {
        void *bus_context;
        const char *name;
 
+       bool async;
        spinlock_t async_lock;
        wait_queue_head_t async_waitq;
        struct list_head async_list;
+       struct list_head async_free;
        int async_ret;
 
 #ifdef CONFIG_DEBUG_FS
@@ -179,6 +180,9 @@ struct regmap_field {
        /* lsb */
        unsigned int shift;
        unsigned int reg;
+
+       unsigned int id_size;
+       unsigned int id_offset;
 };
 
 #ifdef CONFIG_DEBUG_FS
@@ -218,7 +222,7 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
 int regcache_lookup_reg(struct regmap *map, unsigned int reg);
 
 int _regmap_raw_write(struct regmap *map, unsigned int reg,
-                     const void *val, size_t val_len, bool async);
+                     const void *val, size_t val_len);
 
 void regmap_async_complete_cb(struct regmap_async *async, int ret);
 
index d6c2d691b6e862e9ffc29b468dbdc617bc3d4fc0..a36112af494ce34464d989e8037fa96e1a2a2c98 100644 (file)
@@ -631,8 +631,7 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data,
 
        map->cache_bypass = 1;
 
-       ret = _regmap_raw_write(map, base, *data, count * val_bytes,
-                               false);
+       ret = _regmap_raw_write(map, base, *data, count * val_bytes);
 
        map->cache_bypass = 0;
 
index 7d689a15c500bb34ddc3331f33b57512890341aa..ccdac61ac5e2b2b6de72819d8911fd01ad1ecf60 100644 (file)
@@ -42,15 +42,6 @@ static int _regmap_bus_formatted_write(void *context, unsigned int reg,
 static int _regmap_bus_raw_write(void *context, unsigned int reg,
                                 unsigned int val);
 
-static void async_cleanup(struct work_struct *work)
-{
-       struct regmap_async *async = container_of(work, struct regmap_async,
-                                                 cleanup);
-
-       kfree(async->work_buf);
-       kfree(async);
-}
-
 bool regmap_reg_in_ranges(unsigned int reg,
                          const struct regmap_range *ranges,
                          unsigned int nranges)
@@ -465,6 +456,7 @@ struct regmap *regmap_init(struct device *dev,
 
        spin_lock_init(&map->async_lock);
        INIT_LIST_HEAD(&map->async_list);
+       INIT_LIST_HEAD(&map->async_free);
        init_waitqueue_head(&map->async_waitq);
 
        if (config->read_flag_mask || config->write_flag_mask) {
@@ -821,6 +813,8 @@ static void regmap_field_init(struct regmap_field *rm_field,
        rm_field->reg = reg_field.reg;
        rm_field->shift = reg_field.lsb;
        rm_field->mask = ((BIT(field_bits) - 1) << reg_field.lsb);
+       rm_field->id_size = reg_field.id_size;
+       rm_field->id_offset = reg_field.id_offset;
 }
 
 /**
@@ -942,12 +936,22 @@ EXPORT_SYMBOL_GPL(regmap_reinit_cache);
  */
 void regmap_exit(struct regmap *map)
 {
+       struct regmap_async *async;
+
        regcache_exit(map);
        regmap_debugfs_exit(map);
        regmap_range_exit(map);
        if (map->bus && map->bus->free_context)
                map->bus->free_context(map->bus_context);
        kfree(map->work_buf);
+       while (!list_empty(&map->async_free)) {
+               async = list_first_entry_or_null(&map->async_free,
+                                                struct regmap_async,
+                                                list);
+               list_del(&async->list);
+               kfree(async->work_buf);
+               kfree(async);
+       }
        kfree(map);
 }
 EXPORT_SYMBOL_GPL(regmap_exit);
@@ -1039,7 +1043,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg,
 }
 
 int _regmap_raw_write(struct regmap *map, unsigned int reg,
-                     const void *val, size_t val_len, bool async)
+                     const void *val, size_t val_len)
 {
        struct regmap_range_node *range;
        unsigned long flags;
@@ -1091,7 +1095,7 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
                        dev_dbg(map->dev, "Writing window %d/%zu\n",
                                win_residue, val_len / map->format.val_bytes);
                        ret = _regmap_raw_write(map, reg, val, win_residue *
-                                               map->format.val_bytes, async);
+                                               map->format.val_bytes);
                        if (ret != 0)
                                return ret;
 
@@ -1114,21 +1118,42 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
 
        u8[0] |= map->write_flag_mask;
 
-       if (async && map->bus->async_write) {
-               struct regmap_async *async = map->bus->async_alloc();
-               if (!async)
-                       return -ENOMEM;
+       /*
+        * Essentially all I/O mechanisms will be faster with a single
+        * buffer to write.  Since register syncs often generate raw
+        * writes of single registers optimise that case.
+        */
+       if (val != work_val && val_len == map->format.val_bytes) {
+               memcpy(work_val, val, map->format.val_bytes);
+               val = work_val;
+       }
+
+       if (map->async && map->bus->async_write) {
+               struct regmap_async *async;
 
                trace_regmap_async_write_start(map->dev, reg, val_len);
 
-               async->work_buf = kzalloc(map->format.buf_size,
-                                         GFP_KERNEL | GFP_DMA);
-               if (!async->work_buf) {
-                       kfree(async);
-                       return -ENOMEM;
+               spin_lock_irqsave(&map->async_lock, flags);
+               async = list_first_entry_or_null(&map->async_free,
+                                                struct regmap_async,
+                                                list);
+               if (async)
+                       list_del(&async->list);
+               spin_unlock_irqrestore(&map->async_lock, flags);
+
+               if (!async) {
+                       async = map->bus->async_alloc();
+                       if (!async)
+                               return -ENOMEM;
+
+                       async->work_buf = kzalloc(map->format.buf_size,
+                                                 GFP_KERNEL | GFP_DMA);
+                       if (!async->work_buf) {
+                               kfree(async);
+                               return -ENOMEM;
+                       }
                }
 
-               INIT_WORK(&async->cleanup, async_cleanup);
                async->map = map;
 
                /* If the caller supplied the value we can use it safely. */
@@ -1152,11 +1177,8 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
                                ret);
 
                        spin_lock_irqsave(&map->async_lock, flags);
-                       list_del(&async->list);
+                       list_move(&async->list, &map->async_free);
                        spin_unlock_irqrestore(&map->async_lock, flags);
-
-                       kfree(async->work_buf);
-                       kfree(async);
                }
 
                return ret;
@@ -1253,7 +1275,7 @@ static int _regmap_bus_raw_write(void *context, unsigned int reg,
                                 map->work_buf +
                                 map->format.reg_bytes +
                                 map->format.pad_bytes,
-                                map->format.val_bytes, false);
+                                map->format.val_bytes);
 }
 
 static inline void *_regmap_map_get_context(struct regmap *map)
@@ -1317,6 +1339,37 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val)
 }
 EXPORT_SYMBOL_GPL(regmap_write);
 
+/**
+ * regmap_write_async(): Write a value to a single register asynchronously
+ *
+ * @map: Register map to write to
+ * @reg: Register to write to
+ * @val: Value to be written
+ *
+ * A value of zero will be returned on success, a negative errno will
+ * be returned in error cases.
+ */
+int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val)
+{
+       int ret;
+
+       if (reg % map->reg_stride)
+               return -EINVAL;
+
+       map->lock(map->lock_arg);
+
+       map->async = true;
+
+       ret = _regmap_write(map, reg, val);
+
+       map->async = false;
+
+       map->unlock(map->lock_arg);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(regmap_write_async);
+
 /**
  * regmap_raw_write(): Write raw values to one or more registers
  *
@@ -1345,7 +1398,7 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
 
        map->lock(map->lock_arg);
 
-       ret = _regmap_raw_write(map, reg, val, val_len, false);
+       ret = _regmap_raw_write(map, reg, val, val_len);
 
        map->unlock(map->lock_arg);
 
@@ -1369,6 +1422,74 @@ int regmap_field_write(struct regmap_field *field, unsigned int val)
 }
 EXPORT_SYMBOL_GPL(regmap_field_write);
 
+/**
+ * regmap_field_update_bits(): Perform a read/modify/write cycle
+ *                              on the register field
+ *
+ * @field: Register field to write to
+ * @mask: Bitmask to change
+ * @val: Value to be written
+ *
+ * A value of zero will be returned on success, a negative errno will
+ * be returned in error cases.
+ */
+int regmap_field_update_bits(struct regmap_field *field, unsigned int mask, unsigned int val)
+{
+       mask = (mask << field->shift) & field->mask;
+
+       return regmap_update_bits(field->regmap, field->reg,
+                                 mask, val << field->shift);
+}
+EXPORT_SYMBOL_GPL(regmap_field_update_bits);
+
+/**
+ * regmap_fields_write(): Write a value to a single register field with port ID
+ *
+ * @field: Register field to write to
+ * @id: port ID
+ * @val: Value to be written
+ *
+ * A value of zero will be returned on success, a negative errno will
+ * be returned in error cases.
+ */
+int regmap_fields_write(struct regmap_field *field, unsigned int id,
+                       unsigned int val)
+{
+       if (id >= field->id_size)
+               return -EINVAL;
+
+       return regmap_update_bits(field->regmap,
+                                 field->reg + (field->id_offset * id),
+                                 field->mask, val << field->shift);
+}
+EXPORT_SYMBOL_GPL(regmap_fields_write);
+
+/**
+ * regmap_fields_update_bits():        Perform a read/modify/write cycle
+ *                              on the register field
+ *
+ * @field: Register field to write to
+ * @id: port ID
+ * @mask: Bitmask to change
+ * @val: Value to be written
+ *
+ * A value of zero will be returned on success, a negative errno will
+ * be returned in error cases.
+ */
+int regmap_fields_update_bits(struct regmap_field *field,  unsigned int id,
+                             unsigned int mask, unsigned int val)
+{
+       if (id >= field->id_size)
+               return -EINVAL;
+
+       mask = (mask << field->shift) & field->mask;
+
+       return regmap_update_bits(field->regmap,
+                                 field->reg + (field->id_offset * id),
+                                 mask, val << field->shift);
+}
+EXPORT_SYMBOL_GPL(regmap_fields_update_bits);
+
 /*
  * regmap_bulk_write(): Write multiple registers to the device
  *
@@ -1426,8 +1547,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
                                return ret;
                }
        } else {
-               ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count,
-                                       false);
+               ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count);
        }
 
        if (val_bytes != 1)
@@ -1473,7 +1593,11 @@ int regmap_raw_write_async(struct regmap *map, unsigned int reg,
 
        map->lock(map->lock_arg);
 
-       ret = _regmap_raw_write(map, reg, val, val_len, true);
+       map->async = true;
+
+       ret = _regmap_raw_write(map, reg, val, val_len);
+
+       map->async = false;
 
        map->unlock(map->lock_arg);
 
@@ -1676,6 +1800,39 @@ int regmap_field_read(struct regmap_field *field, unsigned int *val)
 }
 EXPORT_SYMBOL_GPL(regmap_field_read);
 
+/**
+ * regmap_fields_read(): Read a value to a single register field with port ID
+ *
+ * @field: Register field to read from
+ * @id: port ID
+ * @val: Pointer to store read value
+ *
+ * A value of zero will be returned on success, a negative errno will
+ * be returned in error cases.
+ */
+int regmap_fields_read(struct regmap_field *field, unsigned int id,
+                      unsigned int *val)
+{
+       int ret;
+       unsigned int reg_val;
+
+       if (id >= field->id_size)
+               return -EINVAL;
+
+       ret = regmap_read(field->regmap,
+                         field->reg + (field->id_offset * id),
+                         &reg_val);
+       if (ret != 0)
+               return ret;
+
+       reg_val &= field->mask;
+       reg_val >>= field->shift;
+       *val = reg_val;
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(regmap_fields_read);
+
 /**
  * regmap_bulk_read(): Read multiple registers from the device
  *
@@ -1787,6 +1944,41 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
 }
 EXPORT_SYMBOL_GPL(regmap_update_bits);
 
+/**
+ * regmap_update_bits_async: Perform a read/modify/write cycle on the register
+ *                           map asynchronously
+ *
+ * @map: Register map to update
+ * @reg: Register to update
+ * @mask: Bitmask to change
+ * @val: New value for bitmask
+ *
+ * With most buses the read must be done synchronously so this is most
+ * useful for devices with a cache which do not need to interact with
+ * the hardware to determine the current register value.
+ *
+ * Returns zero for success, a negative number on error.
+ */
+int regmap_update_bits_async(struct regmap *map, unsigned int reg,
+                            unsigned int mask, unsigned int val)
+{
+       bool change;
+       int ret;
+
+       map->lock(map->lock_arg);
+
+       map->async = true;
+
+       ret = _regmap_update_bits(map, reg, mask, val, &change);
+
+       map->async = false;
+
+       map->unlock(map->lock_arg);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(regmap_update_bits_async);
+
 /**
  * regmap_update_bits_check: Perform a read/modify/write cycle on the
  *                           register map and report if updated
@@ -1812,6 +2004,43 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
 }
 EXPORT_SYMBOL_GPL(regmap_update_bits_check);
 
+/**
+ * regmap_update_bits_check_async: Perform a read/modify/write cycle on the
+ *                                 register map asynchronously and report if
+ *                                 updated
+ *
+ * @map: Register map to update
+ * @reg: Register to update
+ * @mask: Bitmask to change
+ * @val: New value for bitmask
+ * @change: Boolean indicating if a write was done
+ *
+ * With most buses the read must be done synchronously so this is most
+ * useful for devices with a cache which do not need to interact with
+ * the hardware to determine the current register value.
+ *
+ * Returns zero for success, a negative number on error.
+ */
+int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
+                                  unsigned int mask, unsigned int val,
+                                  bool *change)
+{
+       int ret;
+
+       map->lock(map->lock_arg);
+
+       map->async = true;
+
+       ret = _regmap_update_bits(map, reg, mask, val, change);
+
+       map->async = false;
+
+       map->unlock(map->lock_arg);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(regmap_update_bits_check_async);
+
 void regmap_async_complete_cb(struct regmap_async *async, int ret)
 {
        struct regmap *map = async->map;
@@ -1820,8 +2049,7 @@ void regmap_async_complete_cb(struct regmap_async *async, int ret)
        trace_regmap_async_io_complete(map->dev);
 
        spin_lock(&map->async_lock);
-
-       list_del(&async->list);
+       list_move(&async->list, &map->async_free);
        wake = list_empty(&map->async_list);
 
        if (ret != 0)
@@ -1829,8 +2057,6 @@ void regmap_async_complete_cb(struct regmap_async *async, int ret)
 
        spin_unlock(&map->async_lock);
 
-       schedule_work(&async->cleanup);
-
        if (wake)
                wake_up(&map->async_waitq);
 }
index 06189e55b4e5a0479d2eaab0a31610ef91bf472f..94c280d36e8b3bfaea00ee36c4fe3215818b3c86 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
+#include <xen/xen.h>
 #include <xen/events.h>
 #include <xen/interface/io/tpmif.h>
 #include <xen/grant_table.h>
index 32b3479a24051d09a0c1c53647b74848fcb3c967..badf6206b2b20d7284ffbbd098fd66676937fb64 100644 (file)
@@ -383,6 +383,7 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
 static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
 {
        int max_perf, min_perf;
+       u64 val;
 
        intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
 
@@ -394,11 +395,11 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
        trace_cpu_frequency(pstate * 100000, cpu->cpu);
 
        cpu->pstate.current_pstate = pstate;
+       val = pstate << 8;
        if (limits.no_turbo)
-               wrmsrl(MSR_IA32_PERF_CTL, BIT(32) | (pstate << 8));
-       else
-               wrmsrl(MSR_IA32_PERF_CTL, pstate << 8);
+               val |= (u64)1 << 32;
 
+       wrmsrl(MSR_IA32_PERF_CTL, val);
 }
 
 static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps)
@@ -637,8 +638,8 @@ static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
 
 static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
 {
-       int rc, min_pstate, max_pstate;
        struct cpudata *cpu;
+       int rc;
 
        rc = intel_pstate_init_cpu(policy->cpu);
        if (rc)
@@ -652,9 +653,8 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
        else
                policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
-       intel_pstate_get_min_max(cpu, &min_pstate, &max_pstate);
-       policy->min = min_pstate * 100000;
-       policy->max = max_pstate * 100000;
+       policy->min = cpu->pstate.min_pstate * 100000;
+       policy->max = cpu->pstate.turbo_pstate * 100000;
 
        /* cpuinfo and default policy values */
        policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000;
index 8a72b0c555f846da21d25d02d9f94d427a7796b5..15631f92ab7d78cceec876e319c85092c921b8bc 100644 (file)
@@ -166,7 +166,7 @@ static void __init s3c64xx_cpufreq_config_regulator(void)
                if (freq->frequency == CPUFREQ_ENTRY_INVALID)
                        continue;
 
-               dvfs = &s3c64xx_dvfs_table[freq->index];
+               dvfs = &s3c64xx_dvfs_table[freq->driver_data];
                found = 0;
 
                for (i = 0; i < count; i++) {
index 2d9ca6055e5e0bde239247fabe41c960d4dd3020..41b5913ddabe6e0a8b1f417004d86628234b77c5 100644 (file)
@@ -248,14 +248,15 @@ static void lp_gpio_irq_handler(unsigned irq, struct irq_desc *desc)
        struct lp_gpio *lg = irq_data_get_irq_handler_data(data);
        struct irq_chip *chip = irq_data_get_irq_chip(data);
        u32 base, pin, mask;
-       unsigned long reg, pending;
+       unsigned long reg, ena, pending;
        unsigned virq;
 
        /* check from GPIO controller which pin triggered the interrupt */
        for (base = 0; base < lg->chip.ngpio; base += 32) {
                reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT);
+               ena = lp_gpio_reg(&lg->chip, base, LP_INT_ENABLE);
 
-               while ((pending = inl(reg))) {
+               while ((pending = (inl(reg) & inl(ena)))) {
                        pin = __ffs(pending);
                        mask = BIT(pin);
                        /* Clear before handling so we don't lose an edge */
index 86ef3461ec0647b42f1e1ff94a9f47225151f7f6..0dee0e0c247ae5fa2f121df234d09979dc00df74 100644 (file)
@@ -136,7 +136,7 @@ static struct gpio_desc *gpio_to_desc(unsigned gpio)
  */
 static int desc_to_gpio(const struct gpio_desc *desc)
 {
-       return desc->chip->base + gpio_chip_hwgpio(desc);
+       return desc - &gpio_desc[0];
 }
 
 
@@ -1398,7 +1398,7 @@ static int gpiod_request(struct gpio_desc *desc, const char *label)
        int                     status = -EPROBE_DEFER;
        unsigned long           flags;
 
-       if (!desc || !desc->chip) {
+       if (!desc) {
                pr_warn("%s: invalid GPIO\n", __func__);
                return -EINVAL;
        }
@@ -1406,6 +1406,8 @@ static int gpiod_request(struct gpio_desc *desc, const char *label)
        spin_lock_irqsave(&gpio_lock, flags);
 
        chip = desc->chip;
+       if (chip == NULL)
+               goto done;
 
        if (!try_module_get(chip->owner))
                goto done;
index a7b30be86ae06cb7ae59a077aa45ee4e58f52051..52605c0ea3a69fce7c1d312d4fa1610de43174fd 100644 (file)
@@ -525,8 +525,10 @@ static int adf4350_probe(struct spi_device *spi)
        }
 
        indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-       if (indio_dev == NULL)
-               return -ENOMEM;
+       if (indio_dev == NULL) {
+               ret =  -ENOMEM;
+               goto error_disable_clk;
+       }
 
        st = iio_priv(indio_dev);
 
index 2710f7245c3b5472b0e924bd22a94f6bc1212b6f..2db7dcd826b9db6500e354498b385cbb3ebd9f7d 100644 (file)
@@ -477,6 +477,9 @@ void iio_disable_all_buffers(struct iio_dev *indio_dev)
        indio_dev->currentmode = INDIO_DIRECT_MODE;
        if (indio_dev->setup_ops->postdisable)
                indio_dev->setup_ops->postdisable(indio_dev);
+
+       if (indio_dev->available_scan_masks == NULL)
+               kfree(indio_dev->active_scan_mask);
 }
 
 int iio_update_buffers(struct iio_dev *indio_dev,
index d5d1929753e4fdc95bbdc67625f5f0521ffeb32f..cedda25232be2454b3b2f0902152d96a7b1dfd75 100644 (file)
@@ -141,7 +141,7 @@ static const char *to_qp_state_str(int state)
                return "C2_QP_STATE_ERROR";
        default:
                return "<invalid QP state>";
-       };
+       }
 }
 
 void c2_ae_event(struct c2_dev *c2dev, u32 mq_index)
index 3f831de9a4d8a901607afc26c81827cc5c1e3bd5..b1a6cb3a2809282fbfab1b44b09c53e315a93466 100644 (file)
@@ -164,6 +164,7 @@ int mlx5_vector2eqn(struct mlx5_ib_dev *dev, int vector, int *eqn, int *irqn)
 static int alloc_comp_eqs(struct mlx5_ib_dev *dev)
 {
        struct mlx5_eq_table *table = &dev->mdev.priv.eq_table;
+       char name[MLX5_MAX_EQ_NAME];
        struct mlx5_eq *eq, *n;
        int ncomp_vec;
        int nent;
@@ -180,11 +181,10 @@ static int alloc_comp_eqs(struct mlx5_ib_dev *dev)
                        goto clean;
                }
 
-               snprintf(eq->name, MLX5_MAX_EQ_NAME, "mlx5_comp%d", i);
+               snprintf(name, MLX5_MAX_EQ_NAME, "mlx5_comp%d", i);
                err = mlx5_create_map_eq(&dev->mdev, eq,
                                         i + MLX5_EQ_VEC_COMP_BASE, nent, 0,
-                                        eq->name,
-                                        &dev->mdev.priv.uuari.uars[0]);
+                                        name, &dev->mdev.priv.uuari.uars[0]);
                if (err) {
                        kfree(eq);
                        goto clean;
@@ -301,9 +301,8 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
        props->max_srq_sge         = max_rq_sg - 1;
        props->max_fast_reg_page_list_len = (unsigned int)-1;
        props->local_ca_ack_delay  = dev->mdev.caps.local_ca_ack_delay;
-       props->atomic_cap          = dev->mdev.caps.flags & MLX5_DEV_CAP_FLAG_ATOMIC ?
-               IB_ATOMIC_HCA : IB_ATOMIC_NONE;
-       props->masked_atomic_cap   = IB_ATOMIC_HCA;
+       props->atomic_cap          = IB_ATOMIC_NONE;
+       props->masked_atomic_cap   = IB_ATOMIC_NONE;
        props->max_pkeys           = be16_to_cpup((__be16 *)(out_mad->data + 28));
        props->max_mcast_grp       = 1 << dev->mdev.caps.log_max_mcg;
        props->max_mcast_qp_attach = dev->mdev.caps.max_qp_mcg;
@@ -1006,6 +1005,11 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
        ibev.device           = &ibdev->ib_dev;
        ibev.element.port_num = port;
 
+       if (port < 1 || port > ibdev->num_ports) {
+               mlx5_ib_warn(ibdev, "warning: event on port %d\n", port);
+               return;
+       }
+
        if (ibdev->ib_active)
                ib_dispatch_event(&ibev);
 }
index bd41df95b6f0214deb445ab228be8d157373074f..3453580b1eb2cc45800b8ee697157a24cf269970 100644 (file)
@@ -42,6 +42,10 @@ enum {
        DEF_CACHE_SIZE  = 10,
 };
 
+enum {
+       MLX5_UMR_ALIGN  = 2048
+};
+
 static __be64 *mr_align(__be64 *ptr, int align)
 {
        unsigned long mask = align - 1;
@@ -61,13 +65,11 @@ static int order2idx(struct mlx5_ib_dev *dev, int order)
 
 static int add_keys(struct mlx5_ib_dev *dev, int c, int num)
 {
-       struct device *ddev = dev->ib_dev.dma_device;
        struct mlx5_mr_cache *cache = &dev->cache;
        struct mlx5_cache_ent *ent = &cache->ent[c];
        struct mlx5_create_mkey_mbox_in *in;
        struct mlx5_ib_mr *mr;
        int npages = 1 << ent->order;
-       int size = sizeof(u64) * npages;
        int err = 0;
        int i;
 
@@ -83,21 +85,6 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num)
                }
                mr->order = ent->order;
                mr->umred = 1;
-               mr->pas = kmalloc(size + 0x3f, GFP_KERNEL);
-               if (!mr->pas) {
-                       kfree(mr);
-                       err = -ENOMEM;
-                       goto out;
-               }
-               mr->dma = dma_map_single(ddev, mr_align(mr->pas, 0x40), size,
-                                        DMA_TO_DEVICE);
-               if (dma_mapping_error(ddev, mr->dma)) {
-                       kfree(mr->pas);
-                       kfree(mr);
-                       err = -ENOMEM;
-                       goto out;
-               }
-
                in->seg.status = 1 << 6;
                in->seg.xlt_oct_size = cpu_to_be32((npages + 1) / 2);
                in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8);
@@ -108,8 +95,6 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num)
                                            sizeof(*in));
                if (err) {
                        mlx5_ib_warn(dev, "create mkey failed %d\n", err);
-                       dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE);
-                       kfree(mr->pas);
                        kfree(mr);
                        goto out;
                }
@@ -129,11 +114,9 @@ out:
 
 static void remove_keys(struct mlx5_ib_dev *dev, int c, int num)
 {
-       struct device *ddev = dev->ib_dev.dma_device;
        struct mlx5_mr_cache *cache = &dev->cache;
        struct mlx5_cache_ent *ent = &cache->ent[c];
        struct mlx5_ib_mr *mr;
-       int size;
        int err;
        int i;
 
@@ -149,14 +132,10 @@ static void remove_keys(struct mlx5_ib_dev *dev, int c, int num)
                ent->size--;
                spin_unlock(&ent->lock);
                err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr);
-               if (err) {
+               if (err)
                        mlx5_ib_warn(dev, "failed destroy mkey\n");
-               } else {
-                       size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40);
-                       dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE);
-                       kfree(mr->pas);
+               else
                        kfree(mr);
-               }
        }
 }
 
@@ -408,13 +387,12 @@ static void free_cached_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
 
 static void clean_keys(struct mlx5_ib_dev *dev, int c)
 {
-       struct device *ddev = dev->ib_dev.dma_device;
        struct mlx5_mr_cache *cache = &dev->cache;
        struct mlx5_cache_ent *ent = &cache->ent[c];
        struct mlx5_ib_mr *mr;
-       int size;
        int err;
 
+       cancel_delayed_work(&ent->dwork);
        while (1) {
                spin_lock(&ent->lock);
                if (list_empty(&ent->head)) {
@@ -427,14 +405,10 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c)
                ent->size--;
                spin_unlock(&ent->lock);
                err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr);
-               if (err) {
+               if (err)
                        mlx5_ib_warn(dev, "failed destroy mkey\n");
-               } else {
-                       size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40);
-                       dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE);
-                       kfree(mr->pas);
+               else
                        kfree(mr);
-               }
        }
 }
 
@@ -540,13 +514,15 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)
        int i;
 
        dev->cache.stopped = 1;
-       destroy_workqueue(dev->cache.wq);
+       flush_workqueue(dev->cache.wq);
 
        mlx5_mr_cache_debugfs_cleanup(dev);
 
        for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++)
                clean_keys(dev, i);
 
+       destroy_workqueue(dev->cache.wq);
+
        return 0;
 }
 
@@ -675,10 +651,12 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem,
                                  int page_shift, int order, int access_flags)
 {
        struct mlx5_ib_dev *dev = to_mdev(pd->device);
+       struct device *ddev = dev->ib_dev.dma_device;
        struct umr_common *umrc = &dev->umrc;
        struct ib_send_wr wr, *bad;
        struct mlx5_ib_mr *mr;
        struct ib_sge sg;
+       int size = sizeof(u64) * npages;
        int err;
        int i;
 
@@ -697,7 +675,22 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem,
        if (!mr)
                return ERR_PTR(-EAGAIN);
 
-       mlx5_ib_populate_pas(dev, umem, page_shift, mr_align(mr->pas, 0x40), 1);
+       mr->pas = kmalloc(size + MLX5_UMR_ALIGN - 1, GFP_KERNEL);
+       if (!mr->pas) {
+               err = -ENOMEM;
+               goto error;
+       }
+
+       mlx5_ib_populate_pas(dev, umem, page_shift,
+                            mr_align(mr->pas, MLX5_UMR_ALIGN), 1);
+
+       mr->dma = dma_map_single(ddev, mr_align(mr->pas, MLX5_UMR_ALIGN), size,
+                                DMA_TO_DEVICE);
+       if (dma_mapping_error(ddev, mr->dma)) {
+               kfree(mr->pas);
+               err = -ENOMEM;
+               goto error;
+       }
 
        memset(&wr, 0, sizeof(wr));
        wr.wr_id = (u64)(unsigned long)mr;
@@ -718,6 +711,9 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem,
        wait_for_completion(&mr->done);
        up(&umrc->sem);
 
+       dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE);
+       kfree(mr->pas);
+
        if (mr->status != IB_WC_SUCCESS) {
                mlx5_ib_warn(dev, "reg umr failed\n");
                err = -EFAULT;
index 045f8cdbd303deba81e60c5f1f52330b536b9617..5659ea88074108e60d9253085ce89f962326b808 100644 (file)
@@ -203,7 +203,7 @@ static int sq_overhead(enum ib_qp_type qp_type)
 
        switch (qp_type) {
        case IB_QPT_XRC_INI:
-               size = sizeof(struct mlx5_wqe_xrc_seg);
+               size += sizeof(struct mlx5_wqe_xrc_seg);
                /* fall through */
        case IB_QPT_RC:
                size += sizeof(struct mlx5_wqe_ctrl_seg) +
@@ -211,20 +211,23 @@ static int sq_overhead(enum ib_qp_type qp_type)
                        sizeof(struct mlx5_wqe_raddr_seg);
                break;
 
+       case IB_QPT_XRC_TGT:
+               return 0;
+
        case IB_QPT_UC:
-               size = sizeof(struct mlx5_wqe_ctrl_seg) +
+               size += sizeof(struct mlx5_wqe_ctrl_seg) +
                        sizeof(struct mlx5_wqe_raddr_seg);
                break;
 
        case IB_QPT_UD:
        case IB_QPT_SMI:
        case IB_QPT_GSI:
-               size = sizeof(struct mlx5_wqe_ctrl_seg) +
+               size += sizeof(struct mlx5_wqe_ctrl_seg) +
                        sizeof(struct mlx5_wqe_datagram_seg);
                break;
 
        case MLX5_IB_QPT_REG_UMR:
-               size = sizeof(struct mlx5_wqe_ctrl_seg) +
+               size += sizeof(struct mlx5_wqe_ctrl_seg) +
                        sizeof(struct mlx5_wqe_umr_ctrl_seg) +
                        sizeof(struct mlx5_mkey_seg);
                break;
@@ -270,7 +273,8 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr,
                return wqe_size;
 
        if (wqe_size > dev->mdev.caps.max_sq_desc_sz) {
-               mlx5_ib_dbg(dev, "\n");
+               mlx5_ib_dbg(dev, "wqe_size(%d) > max_sq_desc_sz(%d)\n",
+                           wqe_size, dev->mdev.caps.max_sq_desc_sz);
                return -EINVAL;
        }
 
@@ -280,9 +284,15 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr,
 
        wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size);
        qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB;
+       if (qp->sq.wqe_cnt > dev->mdev.caps.max_wqes) {
+               mlx5_ib_dbg(dev, "wqe count(%d) exceeds limits(%d)\n",
+                           qp->sq.wqe_cnt, dev->mdev.caps.max_wqes);
+               return -ENOMEM;
+       }
        qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB);
        qp->sq.max_gs = attr->cap.max_send_sge;
-       qp->sq.max_post = 1 << ilog2(wq_size / wqe_size);
+       qp->sq.max_post = wq_size / wqe_size;
+       attr->cap.max_send_wr = qp->sq.max_post;
 
        return wq_size;
 }
@@ -1280,6 +1290,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
                                          MLX5_QP_OPTPAR_Q_KEY,
                        [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_PKEY_INDEX    |
                                           MLX5_QP_OPTPAR_Q_KEY,
+                       [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH |
+                                         MLX5_QP_OPTPAR_RRE            |
+                                         MLX5_QP_OPTPAR_RAE            |
+                                         MLX5_QP_OPTPAR_RWE            |
+                                         MLX5_QP_OPTPAR_PKEY_INDEX,
                },
        },
        [MLX5_QP_STATE_RTR] = {
@@ -1314,6 +1329,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
                [MLX5_QP_STATE_RTS] = {
                        [MLX5_QP_ST_UD]  = MLX5_QP_OPTPAR_Q_KEY,
                        [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_Q_KEY,
+                       [MLX5_QP_ST_UC]  = MLX5_QP_OPTPAR_RWE,
+                       [MLX5_QP_ST_RC]  = MLX5_QP_OPTPAR_RNR_TIMEOUT   |
+                                          MLX5_QP_OPTPAR_RWE           |
+                                          MLX5_QP_OPTPAR_RAE           |
+                                          MLX5_QP_OPTPAR_RRE,
                },
        },
 };
@@ -1651,29 +1671,6 @@ static __always_inline void set_raddr_seg(struct mlx5_wqe_raddr_seg *rseg,
        rseg->reserved = 0;
 }
 
-static void set_atomic_seg(struct mlx5_wqe_atomic_seg *aseg, struct ib_send_wr *wr)
-{
-       if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP) {
-               aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap);
-               aseg->compare  = cpu_to_be64(wr->wr.atomic.compare_add);
-       } else if (wr->opcode == IB_WR_MASKED_ATOMIC_FETCH_AND_ADD) {
-               aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add);
-               aseg->compare  = cpu_to_be64(wr->wr.atomic.compare_add_mask);
-       } else {
-               aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add);
-               aseg->compare  = 0;
-       }
-}
-
-static void set_masked_atomic_seg(struct mlx5_wqe_masked_atomic_seg *aseg,
-                                 struct ib_send_wr *wr)
-{
-       aseg->swap_add          = cpu_to_be64(wr->wr.atomic.swap);
-       aseg->swap_add_mask     = cpu_to_be64(wr->wr.atomic.swap_mask);
-       aseg->compare           = cpu_to_be64(wr->wr.atomic.compare_add);
-       aseg->compare_mask      = cpu_to_be64(wr->wr.atomic.compare_add_mask);
-}
-
 static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg,
                             struct ib_send_wr *wr)
 {
@@ -2063,28 +2060,11 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
                        case IB_WR_ATOMIC_CMP_AND_SWP:
                        case IB_WR_ATOMIC_FETCH_AND_ADD:
-                               set_raddr_seg(seg, wr->wr.atomic.remote_addr,
-                                             wr->wr.atomic.rkey);
-                               seg  += sizeof(struct mlx5_wqe_raddr_seg);
-
-                               set_atomic_seg(seg, wr);
-                               seg  += sizeof(struct mlx5_wqe_atomic_seg);
-
-                               size += (sizeof(struct mlx5_wqe_raddr_seg) +
-                                        sizeof(struct mlx5_wqe_atomic_seg)) / 16;
-                               break;
-
                        case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
-                               set_raddr_seg(seg, wr->wr.atomic.remote_addr,
-                                             wr->wr.atomic.rkey);
-                               seg  += sizeof(struct mlx5_wqe_raddr_seg);
-
-                               set_masked_atomic_seg(seg, wr);
-                               seg  += sizeof(struct mlx5_wqe_masked_atomic_seg);
-
-                               size += (sizeof(struct mlx5_wqe_raddr_seg) +
-                                        sizeof(struct mlx5_wqe_masked_atomic_seg)) / 16;
-                               break;
+                               mlx5_ib_warn(dev, "Atomic operations are not supported yet\n");
+                               err = -ENOSYS;
+                               *bad_wr = wr;
+                               goto out;
 
                        case IB_WR_LOCAL_INV:
                                next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL;
index 84d297afd6a9889642007a4b3d6b2e0e6e25be74..0aa478bc291ae39aec0ed8c243cce72fe7ed2bdd 100644 (file)
@@ -295,7 +295,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
        mlx5_vfree(in);
        if (err) {
                mlx5_ib_dbg(dev, "create SRQ failed, err %d\n", err);
-               goto err_srq;
+               goto err_usr_kern_srq;
        }
 
        mlx5_ib_dbg(dev, "create SRQ with srqn 0x%x\n", srq->msrq.srqn);
@@ -316,6 +316,8 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
 
 err_core:
        mlx5_core_destroy_srq(&dev->mdev, &srq->msrq);
+
+err_usr_kern_srq:
        if (pd->uobject)
                destroy_srq_user(pd, srq);
        else
index 7c9d35f39d756950b9470d50201f882ca6fba1e3..69020173899397ee5889287ee79f0c3525ab8991 100644 (file)
@@ -357,7 +357,7 @@ static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq)
                        mthca_warn(dev, "Unhandled event %02x(%02x) on EQ %d\n",
                                   eqe->type, eqe->subtype, eq->eqn);
                        break;
-               };
+               }
 
                set_eqe_hw(eqe);
                ++eq->cons_index;
index 4ed8235d2d36d818360cce7e2d43010e0840ab62..50219ab2279d56ae6599e7189b06034bf12049d9 100644 (file)
@@ -150,7 +150,7 @@ enum ib_qp_state get_ibqp_state(enum ocrdma_qp_state qps)
                return IB_QPS_SQE;
        case OCRDMA_QPS_ERR:
                return IB_QPS_ERR;
-       };
+       }
        return IB_QPS_ERR;
 }
 
@@ -171,7 +171,7 @@ static enum ocrdma_qp_state get_ocrdma_qp_state(enum ib_qp_state qps)
                return OCRDMA_QPS_SQE;
        case IB_QPS_ERR:
                return OCRDMA_QPS_ERR;
-       };
+       }
        return OCRDMA_QPS_ERR;
 }
 
@@ -1982,7 +1982,7 @@ int ocrdma_mbx_create_qp(struct ocrdma_qp *qp, struct ib_qp_init_attr *attrs,
                break;
        default:
                return -EINVAL;
-       };
+       }
 
        cmd = ocrdma_init_emb_mqe(OCRDMA_CMD_CREATE_QP, sizeof(*cmd));
        if (!cmd)
index 56e004940f1806c9203e788985395ea4ea5bdddb..0ce7674621eaba2aa310fef332695b67f3057971 100644 (file)
@@ -531,7 +531,7 @@ static void ocrdma_event_handler(struct ocrdma_dev *dev, u32 event)
        case BE_DEV_DOWN:
                ocrdma_close(dev);
                break;
-       };
+       }
 }
 
 static struct ocrdma_driver ocrdma_drv = {
index 6e982bb43c3172d2cc36b844c1b97f8bb0960237..69f1d1221a6bea07039fc37b5ead33f941fc74a4 100644 (file)
@@ -141,7 +141,7 @@ static inline void get_link_speed_and_width(struct ocrdma_dev *dev,
                /* Unsupported */
                *ib_speed = IB_SPEED_SDR;
                *ib_width = IB_WIDTH_1X;
-       };
+       }
 }
 
 
@@ -2331,7 +2331,7 @@ static enum ib_wc_status ocrdma_to_ibwc_err(u16 status)
        default:
                ibwc_status = IB_WC_GENERAL_ERR;
                break;
-       };
+       }
        return ibwc_status;
 }
 
@@ -2370,7 +2370,7 @@ static void ocrdma_update_wc(struct ocrdma_qp *qp, struct ib_wc *ibwc,
                pr_err("%s() invalid opcode received = 0x%x\n",
                       __func__, hdr->cw & OCRDMA_WQE_OPCODE_MASK);
                break;
-       };
+       }
 }
 
 static void ocrdma_set_cqe_status_flushed(struct ocrdma_qp *qp,
index 4caa8e6d59d7968584e23a9187bc07f8c81df321..2d2b1b7588d7e476b7fc814a63c82bad2edb1ed6 100644 (file)
@@ -269,6 +269,14 @@ static chunk_t area_location(struct pstore *ps, chunk_t area)
        return NUM_SNAPSHOT_HDR_CHUNKS + ((ps->exceptions_per_area + 1) * area);
 }
 
+static void skip_metadata(struct pstore *ps)
+{
+       uint32_t stride = ps->exceptions_per_area + 1;
+       chunk_t next_free = ps->next_free;
+       if (sector_div(next_free, stride) == NUM_SNAPSHOT_HDR_CHUNKS)
+               ps->next_free++;
+}
+
 /*
  * Read or write a metadata area.  Remembering to skip the first
  * chunk which holds the header.
@@ -502,6 +510,8 @@ static int read_exceptions(struct pstore *ps,
 
        ps->current_area--;
 
+       skip_metadata(ps);
+
        return 0;
 }
 
@@ -616,8 +626,6 @@ static int persistent_prepare_exception(struct dm_exception_store *store,
                                        struct dm_exception *e)
 {
        struct pstore *ps = get_info(store);
-       uint32_t stride;
-       chunk_t next_free;
        sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev);
 
        /* Is there enough room ? */
@@ -630,10 +638,8 @@ static int persistent_prepare_exception(struct dm_exception_store *store,
         * Move onto the next free pending, making sure to take
         * into account the location of the metadata chunks.
         */
-       stride = (ps->exceptions_per_area + 1);
-       next_free = ++ps->next_free;
-       if (sector_div(next_free, stride) == 1)
-               ps->next_free++;
+       ps->next_free++;
+       skip_metadata(ps);
 
        atomic_inc(&ps->pending_count);
        return 0;
index 2a9b100c48259deed696305ada91a65faa8b4e46..dbbf8ee3f592369fdd5aa968148e7aa307246580 100644 (file)
@@ -158,8 +158,6 @@ int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val)
 {
        int ret;
 
-       BUG_ON(!mutex_is_locked(&mc13xxx->lock));
-
        if (offset > MC13XXX_NUMREGS)
                return -EINVAL;
 
@@ -172,8 +170,6 @@ EXPORT_SYMBOL(mc13xxx_reg_read);
 
 int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val)
 {
-       BUG_ON(!mutex_is_locked(&mc13xxx->lock));
-
        dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val);
 
        if (offset > MC13XXX_NUMREGS || val > 0xffffff)
@@ -186,7 +182,6 @@ EXPORT_SYMBOL(mc13xxx_reg_write);
 int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset,
                u32 mask, u32 val)
 {
-       BUG_ON(!mutex_is_locked(&mc13xxx->lock));
        BUG_ON(val & ~mask);
        dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x (mask: 0x%06x)\n",
                        offset, val, mask);
index 77189daadf1e774c44714beed041d89d08870e4b..5f14ef6693c22abd073b62ea6114dab2b09d76b8 100644 (file)
@@ -94,10 +94,15 @@ static int mc13xxx_spi_write(void *context, const void *data, size_t count)
 {
        struct device *dev = context;
        struct spi_device *spi = to_spi_device(dev);
+       const char *reg = data;
 
        if (count != 4)
                return -ENOTSUPP;
 
+       /* include errata fix for spi audio problems */
+       if (*reg == MC13783_AUDIO_CODEC || *reg == MC13783_AUDIO_DAC)
+               spi_write(spi, data, count);
+
        return spi_write(spi, data, count);
 }
 
index 5472cbd34028d9038539824c4167a0c3010a3a01..6ca30739625f7ac568d693b5d4b9d3d9e47b46de 100644 (file)
@@ -180,28 +180,32 @@ static int verify_block_sig(struct mlx5_cmd_prot_block *block)
        return 0;
 }
 
-static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token)
+static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token,
+                          int csum)
 {
        block->token = token;
-       block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 2);
-       block->sig = ~xor8_buf(block, sizeof(*block) - 1);
+       if (csum) {
+               block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) -
+                                           sizeof(block->data) - 2);
+               block->sig = ~xor8_buf(block, sizeof(*block) - 1);
+       }
 }
 
-static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token)
+static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token, int csum)
 {
        struct mlx5_cmd_mailbox *next = msg->next;
 
        while (next) {
-               calc_block_sig(next->buf, token);
+               calc_block_sig(next->buf, token, csum);
                next = next->next;
        }
 }
 
-static void set_signature(struct mlx5_cmd_work_ent *ent)
+static void set_signature(struct mlx5_cmd_work_ent *ent, int csum)
 {
        ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay));
-       calc_chain_sig(ent->in, ent->token);
-       calc_chain_sig(ent->out, ent->token);
+       calc_chain_sig(ent->in, ent->token, csum);
+       calc_chain_sig(ent->out, ent->token, csum);
 }
 
 static void poll_timeout(struct mlx5_cmd_work_ent *ent)
@@ -539,8 +543,7 @@ static void cmd_work_handler(struct work_struct *work)
        lay->type = MLX5_PCI_CMD_XPORT;
        lay->token = ent->token;
        lay->status_own = CMD_OWNER_HW;
-       if (!cmd->checksum_disabled)
-               set_signature(ent);
+       set_signature(ent, !cmd->checksum_disabled);
        dump_command(dev, ent, 1);
        ktime_get_ts(&ent->ts1);
 
@@ -773,8 +776,6 @@ static int mlx5_copy_from_msg(void *to, struct mlx5_cmd_msg *from, int size)
 
                copy = min_t(int, size, MLX5_CMD_DATA_BLOCK_SIZE);
                block = next->buf;
-               if (xor8_buf(block, sizeof(*block)) != 0xff)
-                       return -EINVAL;
 
                memcpy(to, block->data, copy);
                to += copy;
@@ -1361,6 +1362,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
                goto err_map;
        }
 
+       cmd->checksum_disabled = 1;
        cmd->max_reg_cmds = (1 << cmd->log_sz) - 1;
        cmd->bitmask = (1 << cmd->max_reg_cmds) - 1;
 
@@ -1510,7 +1512,7 @@ int mlx5_cmd_status_to_err(struct mlx5_outbox_hdr *hdr)
        case MLX5_CMD_STAT_BAD_SYS_STATE_ERR:           return -EIO;
        case MLX5_CMD_STAT_BAD_RES_ERR:                 return -EINVAL;
        case MLX5_CMD_STAT_RES_BUSY:                    return -EBUSY;
-       case MLX5_CMD_STAT_LIM_ERR:                     return -EINVAL;
+       case MLX5_CMD_STAT_LIM_ERR:                     return -ENOMEM;
        case MLX5_CMD_STAT_BAD_RES_STATE_ERR:           return -EINVAL;
        case MLX5_CMD_STAT_IX_ERR:                      return -EINVAL;
        case MLX5_CMD_STAT_NO_RES_ERR:                  return -EAGAIN;
index 443cc4d7b024c02d2cc77861868e1c1b17ee2524..2231d93cc7ad116e55c77e0269fa27878f6c6a4d 100644 (file)
@@ -366,9 +366,11 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx,
                goto err_in;
        }
 
+       snprintf(eq->name, MLX5_MAX_EQ_NAME, "%s@pci:%s",
+                name, pci_name(dev->pdev));
        eq->eqn = out.eq_number;
        err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0,
-                         name, eq);
+                         eq->name, eq);
        if (err)
                goto err_eq;
 
index b47739b0b5f6dfb34139ad74e02ac10db1d4fbbd..bc0f5fb66e249dc2e652b4126f9b907707b87c6c 100644 (file)
@@ -165,9 +165,7 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
        struct mlx5_cmd_set_hca_cap_mbox_in *set_ctx = NULL;
        struct mlx5_cmd_query_hca_cap_mbox_in query_ctx;
        struct mlx5_cmd_set_hca_cap_mbox_out set_out;
-       struct mlx5_profile *prof = dev->profile;
        u64 flags;
-       int csum = 1;
        int err;
 
        memset(&query_ctx, 0, sizeof(query_ctx));
@@ -197,20 +195,14 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
        memcpy(&set_ctx->hca_cap, &query_out->hca_cap,
               sizeof(set_ctx->hca_cap));
 
-       if (prof->mask & MLX5_PROF_MASK_CMDIF_CSUM) {
-               csum = !!prof->cmdif_csum;
-               flags = be64_to_cpu(set_ctx->hca_cap.flags);
-               if (csum)
-                       flags |= MLX5_DEV_CAP_FLAG_CMDIF_CSUM;
-               else
-                       flags &= ~MLX5_DEV_CAP_FLAG_CMDIF_CSUM;
-
-               set_ctx->hca_cap.flags = cpu_to_be64(flags);
-       }
-
        if (dev->profile->mask & MLX5_PROF_MASK_QP_SIZE)
                set_ctx->hca_cap.log_max_qp = dev->profile->log_max_qp;
 
+       flags = be64_to_cpu(query_out->hca_cap.flags);
+       /* disable checksum */
+       flags &= ~MLX5_DEV_CAP_FLAG_CMDIF_CSUM;
+
+       set_ctx->hca_cap.flags = cpu_to_be64(flags);
        memset(&set_out, 0, sizeof(set_out));
        set_ctx->hca_cap.log_uar_page_sz = cpu_to_be16(PAGE_SHIFT - 12);
        set_ctx->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_SET_HCA_CAP);
@@ -225,9 +217,6 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
        if (err)
                goto query_ex;
 
-       if (!csum)
-               dev->cmd.checksum_disabled = 1;
-
 query_ex:
        kfree(query_out);
        kfree(set_ctx);
index 3a2408d448203623754d0aa87e35c16e809da43f..7b12acf210f81cd408a4b0e8a965fd4441165c9f 100644 (file)
@@ -90,6 +90,10 @@ struct mlx5_manage_pages_outbox {
        __be64                  pas[0];
 };
 
+enum {
+       MAX_RECLAIM_TIME_MSECS  = 5000,
+};
+
 static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id)
 {
        struct rb_root *root = &dev->priv.page_root;
@@ -279,6 +283,9 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
        int err;
        int i;
 
+       if (nclaimed)
+               *nclaimed = 0;
+
        memset(&in, 0, sizeof(in));
        outlen = sizeof(*out) + npages * sizeof(out->pas[0]);
        out = mlx5_vzalloc(outlen);
@@ -388,20 +395,25 @@ static int optimal_reclaimed_pages(void)
 
 int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev)
 {
-       unsigned long end = jiffies + msecs_to_jiffies(5000);
+       unsigned long end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS);
        struct fw_page *fwp;
        struct rb_node *p;
+       int nclaimed = 0;
        int err;
 
        do {
                p = rb_first(&dev->priv.page_root);
                if (p) {
                        fwp = rb_entry(p, struct fw_page, rb_node);
-                       err = reclaim_pages(dev, fwp->func_id, optimal_reclaimed_pages(), NULL);
+                       err = reclaim_pages(dev, fwp->func_id,
+                                           optimal_reclaimed_pages(),
+                                           &nclaimed);
                        if (err) {
                                mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", err);
                                return err;
                        }
+                       if (nclaimed)
+                               end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS);
                }
                if (time_after(jiffies, end)) {
                        mlx5_core_warn(dev, "FW did not return all pages. giving up...\n");
index 9d2009a9004d14bc6f80bc9e6192a478fc9362aa..78cc76053328c2c8c70bff559f5dc0f903a241df 100644 (file)
@@ -74,10 +74,4 @@ config OF_MTD
        depends on MTD
        def_bool y
 
-config OF_RESERVED_MEM
-       depends on OF_FLATTREE && (DMA_CMA || (HAVE_GENERIC_DMA_COHERENT && HAVE_MEMBLOCK))
-       def_bool y
-       help
-         Initialization code for DMA reserved memory
-
 endmenu # OF
index ed9660adad7751357b49914fcb046fa64470767c..efd05102c40533100794b7d6a7626f583a1f0cdc 100644 (file)
@@ -9,4 +9,3 @@ obj-$(CONFIG_OF_MDIO)   += of_mdio.o
 obj-$(CONFIG_OF_PCI)   += of_pci.o
 obj-$(CONFIG_OF_PCI_IRQ)  += of_pci_irq.o
 obj-$(CONFIG_OF_MTD)   += of_mtd.o
-obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
index 865d3f66c86b2735810e1f6d4d7a219dfd9b350e..7d4c70f859e30687bcd0892c195f9cbfc34826dc 100644 (file)
@@ -303,10 +303,8 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
        struct device_node *cpun, *cpus;
 
        cpus = of_find_node_by_path("/cpus");
-       if (!cpus) {
-               pr_warn("Missing cpus node, bailing out\n");
+       if (!cpus)
                return NULL;
-       }
 
        for_each_child_of_node(cpus, cpun) {
                if (of_node_cmp(cpun->type, "cpu"))
index 229dd9d69e180529cc7e3135d71001421ab9deea..a4fa9ad31b8f7cfb62f45abf47ada0649d87b867 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
-#include <linux/random.h>
 
 #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
 #ifdef CONFIG_PPC
@@ -803,14 +802,3 @@ void __init unflatten_device_tree(void)
 }
 
 #endif /* CONFIG_OF_EARLY_FLATTREE */
-
-/* Feed entire flattened device tree into the random pool */
-static int __init add_fdt_randomness(void)
-{
-       if (initial_boot_params)
-               add_device_randomness(initial_boot_params,
-                               be32_to_cpu(initial_boot_params->totalsize));
-
-       return 0;
-}
-core_initcall(add_fdt_randomness);
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
deleted file mode 100644 (file)
index 0fe40c7..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Device tree based initialization code for reserved memory.
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd.
- *             http://www.samsung.com
- * Author: Marek Szyprowski <m.szyprowski@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License or (at your optional) any later version of the license.
- */
-
-#include <linux/memblock.h>
-#include <linux/err.h>
-#include <linux/of.h>
-#include <linux/of_fdt.h>
-#include <linux/of_platform.h>
-#include <linux/mm.h>
-#include <linux/sizes.h>
-#include <linux/mm_types.h>
-#include <linux/dma-contiguous.h>
-#include <linux/dma-mapping.h>
-#include <linux/of_reserved_mem.h>
-
-#define MAX_RESERVED_REGIONS   16
-struct reserved_mem {
-       phys_addr_t             base;
-       unsigned long           size;
-       struct cma              *cma;
-       char                    name[32];
-};
-static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
-static int reserved_mem_count;
-
-static int __init fdt_scan_reserved_mem(unsigned long node, const char *uname,
-                                       int depth, void *data)
-{
-       struct reserved_mem *rmem = &reserved_mem[reserved_mem_count];
-       phys_addr_t base, size;
-       int is_cma, is_reserved;
-       unsigned long len;
-       const char *status;
-       __be32 *prop;
-
-       is_cma = IS_ENABLED(CONFIG_DMA_CMA) &&
-              of_flat_dt_is_compatible(node, "linux,contiguous-memory-region");
-       is_reserved = of_flat_dt_is_compatible(node, "reserved-memory-region");
-
-       if (!is_reserved && !is_cma) {
-               /* ignore node and scan next one */
-               return 0;
-       }
-
-       status = of_get_flat_dt_prop(node, "status", &len);
-       if (status && strcmp(status, "okay") != 0) {
-               /* ignore disabled node nad scan next one */
-               return 0;
-       }
-
-       prop = of_get_flat_dt_prop(node, "reg", &len);
-       if (!prop || (len < (dt_root_size_cells + dt_root_addr_cells) *
-                            sizeof(__be32))) {
-               pr_err("Reserved mem: node %s, incorrect \"reg\" property\n",
-                      uname);
-               /* ignore node and scan next one */
-               return 0;
-       }
-       base = dt_mem_next_cell(dt_root_addr_cells, &prop);
-       size = dt_mem_next_cell(dt_root_size_cells, &prop);
-
-       if (!size) {
-               /* ignore node and scan next one */
-               return 0;
-       }
-
-       pr_info("Reserved mem: found %s, memory base %lx, size %ld MiB\n",
-               uname, (unsigned long)base, (unsigned long)size / SZ_1M);
-
-       if (reserved_mem_count == ARRAY_SIZE(reserved_mem))
-               return -ENOSPC;
-
-       rmem->base = base;
-       rmem->size = size;
-       strlcpy(rmem->name, uname, sizeof(rmem->name));
-
-       if (is_cma) {
-               struct cma *cma;
-               if (dma_contiguous_reserve_area(size, base, 0, &cma) == 0) {
-                       rmem->cma = cma;
-                       reserved_mem_count++;
-                       if (of_get_flat_dt_prop(node,
-                                               "linux,default-contiguous-region",
-                                               NULL))
-                               dma_contiguous_set_default(cma);
-               }
-       } else if (is_reserved) {
-               if (memblock_remove(base, size) == 0)
-                       reserved_mem_count++;
-               else
-                       pr_err("Failed to reserve memory for %s\n", uname);
-       }
-
-       return 0;
-}
-
-static struct reserved_mem *get_dma_memory_region(struct device *dev)
-{
-       struct device_node *node;
-       const char *name;
-       int i;
-
-       node = of_parse_phandle(dev->of_node, "memory-region", 0);
-       if (!node)
-               return NULL;
-
-       name = kbasename(node->full_name);
-       for (i = 0; i < reserved_mem_count; i++)
-               if (strcmp(name, reserved_mem[i].name) == 0)
-                       return &reserved_mem[i];
-       return NULL;
-}
-
-/**
- * of_reserved_mem_device_init() - assign reserved memory region to given device
- *
- * This function assign memory region pointed by "memory-region" device tree
- * property to the given device.
- */
-void of_reserved_mem_device_init(struct device *dev)
-{
-       struct reserved_mem *region = get_dma_memory_region(dev);
-       if (!region)
-               return;
-
-       if (region->cma) {
-               dev_set_cma_area(dev, region->cma);
-               pr_info("Assigned CMA %s to %s device\n", region->name,
-                       dev_name(dev));
-       } else {
-               if (dma_declare_coherent_memory(dev, region->base, region->base,
-                   region->size, DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) != 0)
-                       pr_info("Declared reserved memory %s to %s device\n",
-                               region->name, dev_name(dev));
-       }
-}
-
-/**
- * of_reserved_mem_device_release() - release reserved memory device structures
- *
- * This function releases structures allocated for memory region handling for
- * the given device.
- */
-void of_reserved_mem_device_release(struct device *dev)
-{
-       struct reserved_mem *region = get_dma_memory_region(dev);
-       if (!region && !region->cma)
-               dma_release_declared_memory(dev);
-}
-
-/**
- * early_init_dt_scan_reserved_mem() - create reserved memory regions
- *
- * This function grabs memory from early allocator for device exclusive use
- * defined in device tree structures. It should be called by arch specific code
- * once the early allocator (memblock) has been activated and all other
- * subsystems have already allocated/reserved memory.
- */
-void __init early_init_dt_scan_reserved_mem(void)
-{
-       of_scan_flat_dt_by_path("/memory/reserved-memory",
-                               fdt_scan_reserved_mem, NULL);
-}
index 9b439ac63d8e73eef85aa490d5cab6ec825120b7..f6dcde22082155577b3cdf0b0f55f103e059cae6 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
-#include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
 
 const struct of_device_id of_default_bus_match_table[] = {
@@ -219,8 +218,6 @@ static struct platform_device *of_platform_device_create_pdata(
        dev->dev.bus = &platform_bus_type;
        dev->dev.platform_data = platform_data;
 
-       of_reserved_mem_device_init(&dev->dev);
-
        /* We do not fill the DMA ops for platform devices by default.
         * This is currently the responsibility of the platform code
         * to do such, possibly using a device notifier
@@ -228,7 +225,6 @@ static struct platform_device *of_platform_device_create_pdata(
 
        if (of_device_add(dev) != 0) {
                platform_device_put(dev);
-               of_reserved_mem_device_release(&dev->dev);
                return NULL;
        }
 
index 0b7d23b4ad954489b657480d0ee08a3b7b2d81d8..be12fbfcae1042e90c00d192bffe46c47821b6c4 100644 (file)
@@ -994,14 +994,16 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
 
                /*
                 * This bridge should have been registered as a hotplug function
-                * under its parent, so the context has to be there.  If not, we
-                * are in deep goo.
+                * under its parent, so the context should be there, unless the
+                * parent is going to be handled by pciehp, in which case this
+                * bridge is not interesting to us either.
                 */
                mutex_lock(&acpiphp_context_lock);
                context = acpiphp_get_context(handle);
-               if (WARN_ON(!context)) {
+               if (!context) {
                        mutex_unlock(&acpiphp_context_lock);
                        put_device(&bus->dev);
+                       pci_dev_put(bridge->pci_dev);
                        kfree(bridge);
                        return;
                }
index 03ca6c139f1a5c9dd0cc821045bad7b5cb409d51..0b7efb269cf1ae565f52ced999340d45c19c914c 100644 (file)
@@ -23,7 +23,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#define TPACPI_VERSION "0.24"
+#define TPACPI_VERSION "0.25"
 #define TPACPI_SYSFS_VERSION 0x020700
 
 /*
@@ -88,6 +88,7 @@
 
 #include <linux/pci_ids.h>
 
+#include <linux/thinkpad_acpi.h>
 
 /* ThinkPad CMOS commands */
 #define TP_CMOS_VOLUME_DOWN    0
@@ -8350,6 +8351,91 @@ static struct ibm_struct fan_driver_data = {
        .resume = fan_resume,
 };
 
+/*************************************************************************
+ * Mute LED subdriver
+ */
+
+
+struct tp_led_table {
+       acpi_string name;
+       int on_value;
+       int off_value;
+       int state;
+};
+
+static struct tp_led_table led_tables[] = {
+       [TPACPI_LED_MUTE] = {
+               .name = "SSMS",
+               .on_value = 1,
+               .off_value = 0,
+       },
+       [TPACPI_LED_MICMUTE] = {
+               .name = "MMTS",
+               .on_value = 2,
+               .off_value = 0,
+       },
+};
+
+static int mute_led_on_off(struct tp_led_table *t, bool state)
+{
+       acpi_handle temp;
+       int output;
+
+       if (!ACPI_SUCCESS(acpi_get_handle(hkey_handle, t->name, &temp))) {
+               pr_warn("Thinkpad ACPI has no %s interface.\n", t->name);
+               return -EIO;
+       }
+
+       if (!acpi_evalf(hkey_handle, &output, t->name, "dd",
+                       state ? t->on_value : t->off_value))
+               return -EIO;
+
+       t->state = state;
+       return state;
+}
+
+int tpacpi_led_set(int whichled, bool on)
+{
+       struct tp_led_table *t;
+
+       if (whichled < 0 || whichled >= TPACPI_LED_MAX)
+               return -EINVAL;
+
+       t = &led_tables[whichled];
+       if (t->state < 0 || t->state == on)
+               return t->state;
+       return mute_led_on_off(t, on);
+}
+EXPORT_SYMBOL_GPL(tpacpi_led_set);
+
+static int mute_led_init(struct ibm_init_struct *iibm)
+{
+       acpi_handle temp;
+       int i;
+
+       for (i = 0; i < TPACPI_LED_MAX; i++) {
+               struct tp_led_table *t = &led_tables[i];
+               if (ACPI_SUCCESS(acpi_get_handle(hkey_handle, t->name, &temp)))
+                       mute_led_on_off(t, false);
+               else
+                       t->state = -ENODEV;
+       }
+       return 0;
+}
+
+static void mute_led_exit(void)
+{
+       int i;
+
+       for (i = 0; i < TPACPI_LED_MAX; i++)
+               tpacpi_led_set(i, false);
+}
+
+static struct ibm_struct mute_led_driver_data = {
+       .name = "mute_led",
+       .exit = mute_led_exit,
+};
+
 /****************************************************************************
  ****************************************************************************
  *
@@ -8768,6 +8854,10 @@ static struct ibm_init_struct ibms_init[] __initdata = {
                .init = fan_init,
                .data = &fan_driver_data,
        },
+       {
+               .init = mute_led_init,
+               .data = &mute_led_driver_data,
+       },
 };
 
 static int __init set_ibm_param(const char *val, struct kernel_param *kp)
index a0ebbc9ce5cdbacc69cc8c240f8d9fd76e43ec12..042aa077b5b3e166a8453ac0684da1dd024f6785 100644 (file)
@@ -1912,9 +1912,6 @@ static int serial_imx_probe_dt(struct imx_port *sport,
 
        sport->devdata = of_id->data;
 
-       if (of_device_is_stdout_path(np))
-               add_preferred_console(imx_reg.cons->name, sport->port.line, 0);
-
        return 0;
 }
 #else
index 93b697a0de658ddc6769fedbe822b1151fef4bab..15ad6fcda88b323b2f5711b753ee76126741ea04 100644 (file)
@@ -561,12 +561,13 @@ static int vt8500_serial_probe(struct platform_device *pdev)
        if (!mmres || !irqres)
                return -ENODEV;
 
-       if (np)
+       if (np) {
                port = of_alias_get_id(np, "serial");
                if (port >= VT8500_MAX_PORTS)
                        port = -1;
-       else
+       } else {
                port = -1;
+       }
 
        if (port < 0) {
                /* calculate the port id */
index 6f96795dd20cc3ff3d0c08490ae8d87b0b2ccccf..64d7a6d9a1adcbd679258661a6b5875bd8bf834a 100644 (file)
@@ -100,8 +100,10 @@ static void host_stop(struct ci_hdrc *ci)
 {
        struct usb_hcd *hcd = ci->hcd;
 
-       usb_remove_hcd(hcd);
-       usb_put_hcd(hcd);
+       if (hcd) {
+               usb_remove_hcd(hcd);
+               usb_put_hcd(hcd);
+       }
        if (ci->platdata->reg_vbus)
                regulator_disable(ci->platdata->reg_vbus);
 }
index 5b44cd47da5b28b30046bead355aa54eda3eec0f..01fe36273f3b144cb1c1fe3306ebdf16459c605f 100644 (file)
@@ -97,6 +97,9 @@ static const struct usb_device_id usb_quirk_list[] = {
        /* Alcor Micro Corp. Hub */
        { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
 
+       /* MicroTouch Systems touchscreen */
+       { USB_DEVICE(0x0596, 0x051e), .driver_info = USB_QUIRK_RESET_RESUME },
+
        /* appletouch */
        { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
 
@@ -130,6 +133,9 @@ static const struct usb_device_id usb_quirk_list[] = {
        /* Broadcom BCM92035DGROM BT dongle */
        { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
 
+       /* MAYA44USB sound device */
+       { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME },
+
        /* Action Semiconductor flash disk */
        { USB_DEVICE(0x10d6, 0x2200), .driver_info =
                        USB_QUIRK_STRING_FETCH_255 },
index 2c76ef1320eab679e1dd1aabd1c8466981392efc..08ef2829a7e2b1c06bbd0af51f308884c8ad9a26 100644 (file)
@@ -799,7 +799,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
         * switchable ports.
         */
        pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
-                       cpu_to_le32(ports_available));
+                       ports_available);
 
        pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
                        &ports_available);
@@ -821,7 +821,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
         * host.
         */
        pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
-                       cpu_to_le32(ports_available));
+                       ports_available);
 
        pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
                        &ports_available);
index 773a6b28c4f1657670547265e0d73caed6366907..e8b4c56dcf62adf1f5326e8609087cd387fedc2e 100644 (file)
@@ -1157,18 +1157,6 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
                t1 = xhci_port_state_to_neutral(t1);
                if (t1 != t2)
                        xhci_writel(xhci, t2, port_array[port_index]);
-
-               if (hcd->speed != HCD_USB3) {
-                       /* enable remote wake up for USB 2.0 */
-                       __le32 __iomem *addr;
-                       u32 tmp;
-
-                       /* Get the port power control register address. */
-                       addr = port_array[port_index] + PORTPMSC;
-                       tmp = xhci_readl(xhci, addr);
-                       tmp |= PORT_RWE;
-                       xhci_writel(xhci, tmp, addr);
-               }
        }
        hcd->state = HC_STATE_SUSPENDED;
        bus_state->next_statechange = jiffies + msecs_to_jiffies(10);
@@ -1247,20 +1235,6 @@ int xhci_bus_resume(struct usb_hcd *hcd)
                                xhci_ring_device(xhci, slot_id);
                } else
                        xhci_writel(xhci, temp, port_array[port_index]);
-
-               if (hcd->speed != HCD_USB3) {
-                       /* disable remote wake up for USB 2.0 */
-                       __le32 __iomem *addr;
-                       u32 tmp;
-
-                       /* Add one to the port status register address to get
-                        * the port power control register address.
-                        */
-                       addr = port_array[port_index] + PORTPMSC;
-                       tmp = xhci_readl(xhci, addr);
-                       tmp &= ~PORT_RWE;
-                       xhci_writel(xhci, tmp, addr);
-               }
        }
 
        (void) xhci_readl(xhci, &xhci->op_regs->command);
index 236c3aabe94083ab5c1829241a46a20d39829587..b8dffd59eb256e52786328e5e4f1919846a80d9c 100644 (file)
@@ -35,6 +35,9 @@
 #define PCI_VENDOR_ID_ETRON            0x1b6f
 #define PCI_DEVICE_ID_ASROCK_P67       0x7023
 
+#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI     0x8c31
+#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI  0x9c31
+
 static const char hcd_name[] = "xhci_hcd";
 
 /* called after powerup, by probe or system-pm "wakeup" */
@@ -69,6 +72,14 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
                                "QUIRK: Fresco Logic xHC needs configure"
                                " endpoint cmd after reset endpoint");
                }
+               if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
+                               pdev->revision == 0x4) {
+                       xhci->quirks |= XHCI_SLOW_SUSPEND;
+                       xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
+                               "QUIRK: Fresco Logic xHC revision %u"
+                               "must be suspended extra slowly",
+                               pdev->revision);
+               }
                /* Fresco Logic confirms: all revisions of this chip do not
                 * support MSI, even though some of them claim to in their PCI
                 * capabilities.
@@ -110,6 +121,15 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
                xhci->quirks |= XHCI_SPURIOUS_REBOOT;
                xhci->quirks |= XHCI_AVOID_BEI;
        }
+       if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
+           (pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI ||
+            pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI)) {
+               /* Workaround for occasional spurious wakeups from S5 (or
+                * any other sleep) on Haswell machines with LPT and LPT-LP
+                * with the new Intel BIOS
+                */
+               xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
+       }
        if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
                        pdev->device == PCI_DEVICE_ID_ASROCK_P67) {
                xhci->quirks |= XHCI_RESET_ON_RESUME;
@@ -217,6 +237,11 @@ static void xhci_pci_remove(struct pci_dev *dev)
                usb_put_hcd(xhci->shared_hcd);
        }
        usb_hcd_pci_remove(dev);
+
+       /* Workaround for spurious wakeups at shutdown with HSW */
+       if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
+               pci_set_power_state(dev, PCI_D3hot);
+
        kfree(xhci);
 }
 
index 1e36dbb4836693dbe5ac90b8231361f82645a7b1..6e0d886bcce52c19361d321cf68c0abacf5b054c 100644 (file)
@@ -730,6 +730,9 @@ void xhci_shutdown(struct usb_hcd *hcd)
 
        spin_lock_irq(&xhci->lock);
        xhci_halt(xhci);
+       /* Workaround for spurious wakeups at shutdown with HSW */
+       if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
+               xhci_reset(xhci);
        spin_unlock_irq(&xhci->lock);
 
        xhci_cleanup_msix(xhci);
@@ -737,6 +740,10 @@ void xhci_shutdown(struct usb_hcd *hcd)
        xhci_dbg_trace(xhci, trace_xhci_dbg_init,
                        "xhci_shutdown completed - status = %x",
                        xhci_readl(xhci, &xhci->op_regs->status));
+
+       /* Yet another workaround for spurious wakeups at shutdown with HSW */
+       if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
+               pci_set_power_state(to_pci_dev(hcd->self.controller), PCI_D3hot);
 }
 
 #ifdef CONFIG_PM
@@ -839,6 +846,7 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci)
 int xhci_suspend(struct xhci_hcd *xhci)
 {
        int                     rc = 0;
+       unsigned int            delay = XHCI_MAX_HALT_USEC;
        struct usb_hcd          *hcd = xhci_to_hcd(xhci);
        u32                     command;
 
@@ -861,8 +869,12 @@ int xhci_suspend(struct xhci_hcd *xhci)
        command = xhci_readl(xhci, &xhci->op_regs->command);
        command &= ~CMD_RUN;
        xhci_writel(xhci, command, &xhci->op_regs->command);
+
+       /* Some chips from Fresco Logic need an extraordinary delay */
+       delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1;
+
        if (xhci_handshake(xhci, &xhci->op_regs->status,
-                     STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) {
+                     STS_HALT, STS_HALT, delay)) {
                xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n");
                spin_unlock_irq(&xhci->lock);
                return -ETIMEDOUT;
index 289fbfbae7463f429ef051602e08e7eccb3e06e8..941d5f59e4dcc254770bac770ba024e36a677bad 100644 (file)
@@ -1548,6 +1548,8 @@ struct xhci_hcd {
 #define XHCI_COMP_MODE_QUIRK   (1 << 14)
 #define XHCI_AVOID_BEI         (1 << 15)
 #define XHCI_PLAT              (1 << 16)
+#define XHCI_SLOW_SUSPEND      (1 << 17)
+#define XHCI_SPURIOUS_WAKEUP   (1 << 18)
        unsigned int            num_active_eps;
        unsigned int            limit_active_eps;
        /* There are two roothubs to keep track of bus suspend info for */
index e2b21c1d9c403088d704d12901c8049e329c360f..ba5f70f92888774c5ef900d44c6f8ad941e6b4e9 100644 (file)
@@ -246,6 +246,6 @@ config USB_EZUSB_FX2
 config USB_HSIC_USB3503
        tristate "USB3503 HSIC to USB20 Driver"
        depends on I2C
-       select REGMAP
+       select REGMAP_I2C
        help
          This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver.
index 18e877ffe7b7d8c7393bdf43efdfd0d58e618011..cd70cc8861711015f5443e2b76e969209d9bdb3a 100644 (file)
@@ -921,6 +921,52 @@ static void musb_generic_disable(struct musb *musb)
 
 }
 
+/*
+ * Program the HDRC to start (enable interrupts, dma, etc.).
+ */
+void musb_start(struct musb *musb)
+{
+       void __iomem    *regs = musb->mregs;
+       u8              devctl = musb_readb(regs, MUSB_DEVCTL);
+
+       dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
+
+       /*  Set INT enable registers, enable interrupts */
+       musb->intrtxe = musb->epmask;
+       musb_writew(regs, MUSB_INTRTXE, musb->intrtxe);
+       musb->intrrxe = musb->epmask & 0xfffe;
+       musb_writew(regs, MUSB_INTRRXE, musb->intrrxe);
+       musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
+
+       musb_writeb(regs, MUSB_TESTMODE, 0);
+
+       /* put into basic highspeed mode and start session */
+       musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
+                       | MUSB_POWER_HSENAB
+                       /* ENSUSPEND wedges tusb */
+                       /* | MUSB_POWER_ENSUSPEND */
+                  );
+
+       musb->is_active = 0;
+       devctl = musb_readb(regs, MUSB_DEVCTL);
+       devctl &= ~MUSB_DEVCTL_SESSION;
+
+       /* session started after:
+        * (a) ID-grounded irq, host mode;
+        * (b) vbus present/connect IRQ, peripheral mode;
+        * (c) peripheral initiates, using SRP
+        */
+       if (musb->port_mode != MUSB_PORT_MODE_HOST &&
+                       (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+               musb->is_active = 1;
+       } else {
+               devctl |= MUSB_DEVCTL_SESSION;
+       }
+
+       musb_platform_enable(musb);
+       musb_writeb(regs, MUSB_DEVCTL, devctl);
+}
+
 /*
  * Make the HDRC stop (disable interrupts, etc.);
  * reversible by musb_start
index 65f3917b4fc5fb55c95bf4157d70a1d7194a110d..1c5bf75ee8ff8a45a3da1fca7cb1d31920f0eeff 100644 (file)
@@ -503,6 +503,7 @@ static inline void musb_configure_ep0(struct musb *musb)
 extern const char musb_driver_name[];
 
 extern void musb_stop(struct musb *musb);
+extern void musb_start(struct musb *musb);
 
 extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
 extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);
index b19ed213ab8580c5456cbddaca4f217db31733c4..3671898a4535b3cf2de3c0e188f4947485d2760d 100644 (file)
@@ -1853,11 +1853,14 @@ static int musb_gadget_start(struct usb_gadget *g,
        musb->gadget_driver = driver;
 
        spin_lock_irqsave(&musb->lock, flags);
+       musb->is_active = 1;
 
        otg_set_peripheral(otg, &musb->g);
        musb->xceiv->state = OTG_STATE_B_IDLE;
        spin_unlock_irqrestore(&musb->lock, flags);
 
+       musb_start(musb);
+
        /* REVISIT:  funcall to other code, which also
         * handles power budgeting ... this way also
         * ensures HdrcStart is indirectly called.
index a523950c2b32e66e07f7c8bd78daa181f691f25c..d1d6b83aabca61df43dffccf57ccbe7687cbe399 100644 (file)
 
 #include "musb_core.h"
 
-/*
-* Program the HDRC to start (enable interrupts, dma, etc.).
-*/
-static void musb_start(struct musb *musb)
-{
-       void __iomem    *regs = musb->mregs;
-       u8              devctl = musb_readb(regs, MUSB_DEVCTL);
-
-       dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
-
-       /*  Set INT enable registers, enable interrupts */
-       musb->intrtxe = musb->epmask;
-       musb_writew(regs, MUSB_INTRTXE, musb->intrtxe);
-       musb->intrrxe = musb->epmask & 0xfffe;
-       musb_writew(regs, MUSB_INTRRXE, musb->intrrxe);
-       musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
-
-       musb_writeb(regs, MUSB_TESTMODE, 0);
-
-       /* put into basic highspeed mode and start session */
-       musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
-                                               | MUSB_POWER_HSENAB
-                                               /* ENSUSPEND wedges tusb */
-                                               /* | MUSB_POWER_ENSUSPEND */
-                                               );
-
-       musb->is_active = 0;
-       devctl = musb_readb(regs, MUSB_DEVCTL);
-       devctl &= ~MUSB_DEVCTL_SESSION;
-
-       /* session started after:
-        * (a) ID-grounded irq, host mode;
-        * (b) vbus present/connect IRQ, peripheral mode;
-        * (c) peripheral initiates, using SRP
-        */
-       if (musb->port_mode != MUSB_PORT_MODE_HOST &&
-           (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
-               musb->is_active = 1;
-       } else {
-               devctl |= MUSB_DEVCTL_SESSION;
-       }
-
-       musb_platform_enable(musb);
-       musb_writeb(regs, MUSB_DEVCTL, devctl);
-}
-
 static void musb_port_suspend(struct musb *musb, bool do_suspend)
 {
        struct usb_otg  *otg = musb->xceiv->otg;
index 80a7104d5ddb3e6d81fa125bb13d9a4d0af05dcf..acaee066b99aa10e5ecf2a8e75cffd31899b6507 100644 (file)
@@ -451,6 +451,10 @@ static void option_instat_callback(struct urb *urb);
 #define CHANGHONG_VENDOR_ID                    0x2077
 #define CHANGHONG_PRODUCT_CH690                        0x7001
 
+/* Inovia */
+#define INOVIA_VENDOR_ID                       0x20a6
+#define INOVIA_SEW858                          0x1105
+
 /* some devices interfaces need special handling due to a number of reasons */
 enum option_blacklist_reason {
                OPTION_BLACKLIST_NONE = 0,
@@ -689,6 +693,222 @@ static const struct usb_device_id option_ids[] = {
        { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) },
        { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7B) },
        { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x01) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x02) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x03) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x04) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x05) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x06) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x10) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x12) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x13) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x14) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x15) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x17) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x18) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x19) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x31) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x32) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x33) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x34) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x35) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x36) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x48) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x49) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x61) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x62) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x63) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x64) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x65) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x66) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x01) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x02) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x03) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x04) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x05) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x06) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x10) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x12) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x13) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x14) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x15) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x17) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x18) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x19) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x31) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x32) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x33) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x34) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x35) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x36) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x48) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x49) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x61) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x62) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x63) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x64) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x65) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x66) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x01) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x02) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x03) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x04) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x05) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x06) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x10) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x12) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x13) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x14) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x15) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x17) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x18) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x19) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x31) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x32) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x33) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x34) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x35) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x36) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x48) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x49) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x61) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x62) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x63) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x64) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x65) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x66) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x01) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x02) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x03) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x04) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x05) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x06) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x10) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x12) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x13) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x14) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x15) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x17) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x18) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x19) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x31) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x32) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x33) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x34) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x35) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x36) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x48) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x49) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4C) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x61) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x62) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x63) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x64) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x65) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x66) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7B) },
+       { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) },
 
 
        { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) },
@@ -1257,7 +1477,9 @@ static const struct usb_device_id option_ids[] = {
 
        { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
        { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) },
-       { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200) },
+       { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200),
+               .driver_info = (kernel_ulong_t)&net_intf6_blacklist
+       },
        { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
        { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
        { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) },
@@ -1345,6 +1567,7 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
        { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
        { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
+       { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
        { } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, option_ids);
index 760b78560f67fd7e7d905d53dff2cb7a46f2919f..c9a35697ebe9a6e131d5a9c145e5f3f3415dd5bf 100644 (file)
@@ -190,6 +190,7 @@ static struct usb_device_id ti_id_table_combined[] = {
        { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
        { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
        { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
+       { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) },
        { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
        { }     /* terminator */
 };
index 94d75edef77fdf34e4f5e341e5952e532f03f09e..18509e6c21ab84e7d3133f7a0e428ba462d2a24b 100644 (file)
@@ -211,8 +211,11 @@ static int slave_configure(struct scsi_device *sdev)
                /*
                 * Many devices do not respond properly to READ_CAPACITY_16.
                 * Tell the SCSI layer to try READ_CAPACITY_10 first.
+                * However some USB 3.0 drive enclosures return capacity
+                * modulo 2TB. Those must use READ_CAPACITY_16
                 */
-               sdev->try_rc_10_first = 1;
+               if (!(us->fflags & US_FL_NEEDS_CAP16))
+                       sdev->try_rc_10_first = 1;
 
                /* assume SPC3 or latter devices support sense size > 18 */
                if (sdev->scsi_level > SCSI_SPC_2)
index c015f2c16729c5b4030fc829fae9a3cfb90acde6..de32cfa5bfa6ca0772d0955ea83b9b98dd698ea5 100644 (file)
@@ -1925,6 +1925,13 @@ UNUSUAL_DEV(  0x1652, 0x6600, 0x0201, 0x0201,
                USB_SC_DEVICE, USB_PR_DEVICE, NULL,
                US_FL_IGNORE_RESIDUE ),
 
+/* Reported by Oliver Neukum <oneukum@suse.com> */
+UNUSUAL_DEV(  0x174c, 0x55aa, 0x0100, 0x0100,
+               "ASMedia",
+               "AS2105",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_NEEDS_CAP16),
+
 /* Reported by Jesse Feddema <jdfeddema@gmail.com> */
 UNUSUAL_DEV(  0x177f, 0x0400, 0x0000, 0x0000,
                "Yarvik",
index a9807dea3887af0afe44e545784f70d46efa40dd..4fb7a8f83c8a99ff8d3412a5328b2407c98409a8 100644 (file)
@@ -545,6 +545,8 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
        long npage;
        int ret = 0, prot = 0;
        uint64_t mask;
+       struct vfio_dma *dma = NULL;
+       unsigned long pfn;
 
        end = map->iova + map->size;
 
@@ -587,8 +589,6 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
        }
 
        for (iova = map->iova; iova < end; iova += size, vaddr += size) {
-               struct vfio_dma *dma = NULL;
-               unsigned long pfn;
                long i;
 
                /* Pin a contiguous chunk of memory */
@@ -597,16 +597,15 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
                if (npage <= 0) {
                        WARN_ON(!npage);
                        ret = (int)npage;
-                       break;
+                       goto out;
                }
 
                /* Verify pages are not already mapped */
                for (i = 0; i < npage; i++) {
                        if (iommu_iova_to_phys(iommu->domain,
                                               iova + (i << PAGE_SHIFT))) {
-                               vfio_unpin_pages(pfn, npage, prot, true);
                                ret = -EBUSY;
-                               break;
+                               goto out_unpin;
                        }
                }
 
@@ -616,8 +615,7 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
                if (ret) {
                        if (ret != -EBUSY ||
                            map_try_harder(iommu, iova, pfn, npage, prot)) {
-                               vfio_unpin_pages(pfn, npage, prot, true);
-                               break;
+                               goto out_unpin;
                        }
                }
 
@@ -672,9 +670,8 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
                        dma = kzalloc(sizeof(*dma), GFP_KERNEL);
                        if (!dma) {
                                iommu_unmap(iommu->domain, iova, size);
-                               vfio_unpin_pages(pfn, npage, prot, true);
                                ret = -ENOMEM;
-                               break;
+                               goto out_unpin;
                        }
 
                        dma->size = size;
@@ -685,16 +682,21 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
                }
        }
 
-       if (ret) {
-               struct vfio_dma *tmp;
-               iova = map->iova;
-               size = map->size;
-               while ((tmp = vfio_find_dma(iommu, iova, size))) {
-                       int r = vfio_remove_dma_overlap(iommu, iova,
-                                                       &size, tmp);
-                       if (WARN_ON(r || !size))
-                               break;
-               }
+       WARN_ON(ret);
+       mutex_unlock(&iommu->lock);
+       return ret;
+
+out_unpin:
+       vfio_unpin_pages(pfn, npage, prot, true);
+
+out:
+       iova = map->iova;
+       size = map->size;
+       while ((dma = vfio_find_dma(iommu, iova, size))) {
+               int r = vfio_remove_dma_overlap(iommu, iova,
+                                               &size, dma);
+               if (WARN_ON(r || !size))
+                       break;
        }
 
        mutex_unlock(&iommu->lock);
index c7c64f18773d87d5f23e81ec90ba7d8bfaee504a..fa932c2f7d97276b66199eda06b6edb6565208bb 100644 (file)
@@ -613,6 +613,9 @@ static int w1_bus_notify(struct notifier_block *nb, unsigned long action,
        sl = dev_to_w1_slave(dev);
        fops = sl->family->fops;
 
+       if (!fops)
+               return 0;
+
        switch (action) {
        case BUS_NOTIFY_ADD_DEVICE:
                /* if the family driver needs to initialize something... */
@@ -713,7 +716,10 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
        atomic_set(&sl->refcnt, 0);
        init_completion(&sl->released);
 
+       /* slave modules need to be loaded in a context with unlocked mutex */
+       mutex_unlock(&dev->mutex);
        request_module("w1-family-0x%0x", rn->family);
+       mutex_lock(&dev->mutex);
 
        spin_lock(&w1_flock);
        f = w1_family_registered(rn->family);
index b0ef7b07b1b3be510e85dd1bab6711e7d27cebee..51e3afa7835479e00fa346241cfccd10b6e60a80 100644 (file)
@@ -6437,6 +6437,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
 
        if (btrfs_extent_readonly(root, disk_bytenr))
                goto out;
+       btrfs_release_path(path);
 
        /*
         * look for other files referencing this extent, if we
index 4d7433534f5cd77b7f9b240fba57ac7923df07e6..6024877335caf2a9dfa6af1018c5da19b0e8a2ae 100644 (file)
@@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block,
        struct buffer_head *bh;
        sector_t end_block;
        int ret = 0;            /* Will call free_more_memory() */
+       gfp_t gfp_mask;
 
-       page = find_or_create_page(inode->i_mapping, index,
-               (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE);
+       gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS;
+       gfp_mask |= __GFP_MOVABLE;
+       /*
+        * XXX: __getblk_slow() can not really deal with failure and
+        * will endlessly loop on improvised global reclaim.  Prefer
+        * looping in the allocator rather than here, at least that
+        * code knows what it's doing.
+        */
+       gfp_mask |= __GFP_NOFAIL;
+
+       page = find_or_create_page(inode->i_mapping, index, gfp_mask);
        if (!page)
                return ret;
 
index a16b4e58bcc62ee88f9772f75120ef250d0112bd..77fc5e181077b1f897cf27d40c140133b6cf6d0f 100644 (file)
@@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb)
 {
        struct inode *inode;
        struct cifs_sb_info *cifs_sb;
+       struct cifs_tcon *tcon;
        int rc = 0;
 
        cifs_sb = CIFS_SB(sb);
+       tcon = cifs_sb_master_tcon(cifs_sb);
 
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
                sb->s_flags |= MS_POSIXACL;
 
-       if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES)
+       if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)
                sb->s_maxbytes = MAX_LFS_FILESIZE;
        else
                sb->s_maxbytes = MAX_NON_LFS;
@@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb)
                goto out_no_root;
        }
 
-       if (cifs_sb_master_tcon(cifs_sb)->nocase)
+       if (tcon->nocase)
                sb->s_d_op = &cifs_ci_dentry_ops;
        else
                sb->s_d_op = &cifs_dentry_ops;
index a630475e421c421ef38f6633ddb31c8351827752..08f9dfb1a894402eec24579717f6c48d4d92f695 100644 (file)
@@ -1491,15 +1491,30 @@ struct file_notify_information {
        __u8  FileName[0];
 } __attribute__((packed));
 
-struct reparse_data {
-       __u32   ReparseTag;
-       __u16   ReparseDataLength;
+/* For IO_REPARSE_TAG_SYMLINK */
+struct reparse_symlink_data {
+       __le32  ReparseTag;
+       __le16  ReparseDataLength;
        __u16   Reserved;
-       __u16   SubstituteNameOffset;
-       __u16   SubstituteNameLength;
-       __u16   PrintNameOffset;
-       __u16   PrintNameLength;
-       __u32   Flags;
+       __le16  SubstituteNameOffset;
+       __le16  SubstituteNameLength;
+       __le16  PrintNameOffset;
+       __le16  PrintNameLength;
+       __le32  Flags;
+       char    PathBuffer[0];
+} __attribute__((packed));
+
+/* For IO_REPARSE_TAG_NFS */
+#define NFS_SPECFILE_LNK       0x00000000014B4E4C
+#define NFS_SPECFILE_CHR       0x0000000000524843
+#define NFS_SPECFILE_BLK       0x00000000004B4C42
+#define NFS_SPECFILE_FIFO      0x000000004F464946
+#define NFS_SPECFILE_SOCK      0x000000004B434F53
+struct reparse_posix_data {
+       __le32  ReparseTag;
+       __le16  ReparseDataLength;
+       __u16   Reserved;
+       __le64  InodeType; /* LNK, FIFO, CHR etc. */
        char    PathBuffer[0];
 } __attribute__((packed));
 
index 4baf35949b51a16a395a698f40b66dd312a14246..ccd31ab815d4b2404d58a0e42f3ad606d35b87f5 100644 (file)
@@ -3088,7 +3088,8 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
        bool is_unicode;
        unsigned int sub_len;
        char *sub_start;
-       struct reparse_data *reparse_buf;
+       struct reparse_symlink_data *reparse_buf;
+       struct reparse_posix_data *posix_buf;
        __u32 data_offset, data_count;
        char *end_of_smb;
 
@@ -3137,20 +3138,47 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
                goto qreparse_out;
        }
        end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount;
-       reparse_buf = (struct reparse_data *)
+       reparse_buf = (struct reparse_symlink_data *)
                                ((char *)&pSMBr->hdr.Protocol + data_offset);
        if ((char *)reparse_buf >= end_of_smb) {
                rc = -EIO;
                goto qreparse_out;
        }
-       if ((reparse_buf->PathBuffer + reparse_buf->PrintNameOffset +
-                               reparse_buf->PrintNameLength) > end_of_smb) {
+       if (reparse_buf->ReparseTag == cpu_to_le32(IO_REPARSE_TAG_NFS)) {
+               cifs_dbg(FYI, "NFS style reparse tag\n");
+               posix_buf =  (struct reparse_posix_data *)reparse_buf;
+
+               if (posix_buf->InodeType != cpu_to_le64(NFS_SPECFILE_LNK)) {
+                       cifs_dbg(FYI, "unsupported file type 0x%llx\n",
+                                le64_to_cpu(posix_buf->InodeType));
+                       rc = -EOPNOTSUPP;
+                       goto qreparse_out;
+               }
+               is_unicode = true;
+               sub_len = le16_to_cpu(reparse_buf->ReparseDataLength);
+               if (posix_buf->PathBuffer + sub_len > end_of_smb) {
+                       cifs_dbg(FYI, "reparse buf beyond SMB\n");
+                       rc = -EIO;
+                       goto qreparse_out;
+               }
+               *symlinkinfo = cifs_strndup_from_utf16(posix_buf->PathBuffer,
+                               sub_len, is_unicode, nls_codepage);
+               goto qreparse_out;
+       } else if (reparse_buf->ReparseTag !=
+                       cpu_to_le32(IO_REPARSE_TAG_SYMLINK)) {
+               rc = -EOPNOTSUPP;
+               goto qreparse_out;
+       }
+
+       /* Reparse tag is NTFS symlink */
+       sub_start = le16_to_cpu(reparse_buf->SubstituteNameOffset) +
+                               reparse_buf->PathBuffer;
+       sub_len = le16_to_cpu(reparse_buf->SubstituteNameLength);
+       if (sub_start + sub_len > end_of_smb) {
                cifs_dbg(FYI, "reparse buf beyond SMB\n");
                rc = -EIO;
                goto qreparse_out;
        }
-       sub_start = reparse_buf->SubstituteNameOffset + reparse_buf->PathBuffer;
-       sub_len = reparse_buf->SubstituteNameLength;
        if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
                is_unicode = true;
        else
index af847e1cf1c1985f5ddadd07e10dbc0e38a162a2..651a5279607b968a255a528e5411e4f4b39ca438 100644 (file)
@@ -780,7 +780,9 @@ static const struct {
        ERRDOS, ERRnoaccess, 0xc0000290}, {
        ERRDOS, ERRbadfunc, 0xc000029c}, {
        ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
-       ERRDOS, ERRinvlevel, 0x007c0001}, };
+       ERRDOS, ERRinvlevel, 0x007c0001}, {
+       0, 0, 0 }
+};
 
 /*****************************************************************************
  Print an error message from the status code
index 352358de1d7e37a8126d61d76898112393f64d08..e87387dbf39fa1d24b19f245e86da4c907b0fdaf 100644 (file)
@@ -500,9 +500,9 @@ select_sectype(struct TCP_Server_Info *server, enum securityEnum requested)
                                return NTLMv2;
                        if (global_secflags & CIFSSEC_MAY_NTLM)
                                return NTLM;
-                       /* Fallthrough */
                default:
-                       return Unspecified;
+                       /* Fallthrough to attempt LANMAN authentication next */
+                       break;
                }
        case CIFS_NEGFLAVOR_LANMAN:
                switch (requested) {
index eba0efde66d70ae15974eef74b10ff6d83ca44d8..edccb5252462b6b465d3d71cb7d3de20e8d2be9a 100644 (file)
@@ -687,6 +687,10 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses)
        else
                return -EIO;
 
+       /* no need to send SMB logoff if uid already closed due to reconnect */
+       if (ses->need_reconnect)
+               goto smb2_session_already_dead;
+
        rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req);
        if (rc)
                return rc;
@@ -701,6 +705,8 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses)
         * No tcon so can't do
         * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);
         */
+
+smb2_session_already_dead:
        return rc;
 }
 
index d952ee48f4dcc629a5d1e91c3470cbd2bd6d1aec..a4b2391fe66e4e11cea93e7396b987c335d43823 100644 (file)
 #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */
 #define FSCTL_SRV_READ_HASH          0x001441BB /* BB add struct */
 
+/* See FSCC 2.1.2.5 */
 #define IO_REPARSE_TAG_MOUNT_POINT   0xA0000003
 #define IO_REPARSE_TAG_HSM           0xC0000004
 #define IO_REPARSE_TAG_SIS           0x80000007
+#define IO_REPARSE_TAG_HSM2          0x80000006
+#define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
+/* Used by the DFS filter. See MS-DFSC */
+#define IO_REPARSE_TAG_DFS           0x8000000A
+/* Used by the DFS filter See MS-DFSC */
+#define IO_REPARSE_TAG_DFSR          0x80000012
+#define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B
+/* See section MS-FSCC 2.1.2.4 */
+#define IO_REPARSE_TAG_SYMLINK       0xA000000C
+#define IO_REPARSE_TAG_DEDUP         0x80000013
+#define IO_REPARSE_APPXSTREAM       0xC0000014
+/* NFS symlinks, Win 8/SMB3 and later */
+#define IO_REPARSE_TAG_NFS           0x80000014
 
 /* fsctl flags */
 /* If Flags is set to this value, the request is an FSCTL not ioctl request */
index 6fdcb1b4a106747779ae77ed365116256e79edec..800b938e4061768f5f55ee414b45afa56e6d6aa2 100644 (file)
@@ -410,8 +410,13 @@ static int
 wait_for_free_request(struct TCP_Server_Info *server, const int timeout,
                      const int optype)
 {
-       return wait_for_free_credits(server, timeout,
-                               server->ops->get_credits_field(server, optype));
+       int *val;
+
+       val = server->ops->get_credits_field(server, optype);
+       /* Since an echo is already inflight, no need to wait to send another */
+       if (*val <= 0 && optype == CIFS_ECHO_OP)
+               return -EAGAIN;
+       return wait_for_free_credits(server, timeout, val);
 }
 
 static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
index 1194b1f0f8396c934ab6a382deadab6c0a6c4c2f..f8cde46de9cd77c3047182e94164bdfdac4a317d 100644 (file)
@@ -1783,7 +1783,7 @@ retry:
                d_tmpfile(dentry, inode);
                err = ext3_orphan_add(handle, inode);
                if (err)
-                       goto err_drop_inode;
+                       goto err_unlock_inode;
                mark_inode_dirty(inode);
                unlock_new_inode(inode);
        }
@@ -1791,10 +1791,9 @@ retry:
        if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
                goto retry;
        return err;
-err_drop_inode:
+err_unlock_inode:
        ext3_journal_stop(handle);
        unlock_new_inode(inode);
-       iput(inode);
        return err;
 }
 
index 1bec5a5c1e45a29e9ead318987ec03d803104c5a..5a0408d7b1147094c3e82b6d11750b33396b7732 100644 (file)
@@ -2319,7 +2319,7 @@ retry:
                d_tmpfile(dentry, inode);
                err = ext4_orphan_add(handle, inode);
                if (err)
-                       goto err_drop_inode;
+                       goto err_unlock_inode;
                mark_inode_dirty(inode);
                unlock_new_inode(inode);
        }
@@ -2328,10 +2328,9 @@ retry:
        if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
                goto retry;
        return err;
-err_drop_inode:
+err_unlock_inode:
        ext4_journal_stop(handle);
        unlock_new_inode(inode);
-       iput(inode);
        return err;
 }
 
index 9f8ef9b7674db1ca1004b682b40a6e5500dcfc24..8eaa1ba793fc188879d405e768a81aedbaa4bf76 100644 (file)
@@ -288,10 +288,14 @@ static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma)
 static unsigned long proc_reg_get_unmapped_area(struct file *file, unsigned long orig_addr, unsigned long len, unsigned long pgoff, unsigned long flags)
 {
        struct proc_dir_entry *pde = PDE(file_inode(file));
-       int rv = -EIO;
-       unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
+       unsigned long rv = -EIO;
+       unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) = NULL;
        if (use_pde(pde)) {
-               get_unmapped_area = pde->proc_fops->get_unmapped_area;
+#ifdef CONFIG_MMU
+               get_unmapped_area = current->mm->get_unmapped_area;
+#endif
+               if (pde->proc_fops->get_unmapped_area)
+                       get_unmapped_area = pde->proc_fops->get_unmapped_area;
                if (get_unmapped_area)
                        rv = get_unmapped_area(file, orig_addr, len, pgoff, flags);
                unuse_pde(pde);
index 7366e9d63cee7d8658e9fed949a2fe7b22519c6f..390bdab01c3c782cc14b55c6d1ef35ebddcc4197 100644 (file)
@@ -941,6 +941,8 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, struct pagemapread *pm,
                frame = pte_pfn(pte);
                flags = PM_PRESENT;
                page = vm_normal_page(vma, addr, pte);
+               if (pte_soft_dirty(pte))
+                       flags2 |= __PM_SOFT_DIRTY;
        } else if (is_swap_pte(pte)) {
                swp_entry_t entry;
                if (pte_swp_soft_dirty(pte))
@@ -960,7 +962,7 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, struct pagemapread *pm,
 
        if (page && !PageAnon(page))
                flags |= PM_FILE;
-       if ((vma->vm_flags & VM_SOFTDIRTY) || pte_soft_dirty(pte))
+       if ((vma->vm_flags & VM_SOFTDIRTY))
                flags2 |= __PM_SOFT_DIRTY;
 
        *pme = make_pme(PM_PFRAME(frame) | PM_STATUS2(pm->v2, flags2) | flags);
index 02e113bb8b7d5c777fdc435a5285208238ce66e9..d9019821aa6020e1c6d974856edfb404cb81d8c8 100644 (file)
@@ -311,7 +311,6 @@ struct acpi_device {
        unsigned int physical_node_count;
        struct list_head physical_node_list;
        struct mutex physical_node_lock;
-       struct list_head power_dependent;
        void (*remove)(struct acpi_device *);
 };
 
@@ -456,8 +455,6 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
 acpi_status acpi_remove_pm_notifier(struct acpi_device *adev,
                                    acpi_notify_handler handler);
 int acpi_pm_device_sleep_state(struct device *, int *, int);
-void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev);
-void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev);
 #else
 static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
                                               acpi_notify_handler handler,
@@ -478,10 +475,6 @@ static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m)
        return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ?
                m : ACPI_STATE_D0;
 }
-static inline void acpi_dev_pm_add_dependent(acpi_handle handle,
-                                            struct device *depdev) {}
-static inline void acpi_dev_pm_remove_dependent(acpi_handle handle,
-                                               struct device *depdev) {}
 #endif
 
 #ifdef CONFIG_PM_RUNTIME
index ecc82b37c4ccf00fb863ecf6981de19bbccec52a..b3e7a667e03c24ca5c3d1c54c0db5c7b0bdde052 100644 (file)
@@ -137,47 +137,24 @@ extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
 extern void mem_cgroup_replace_page_cache(struct page *oldpage,
                                        struct page *newpage);
 
-/**
- * mem_cgroup_toggle_oom - toggle the memcg OOM killer for the current task
- * @new: true to enable, false to disable
- *
- * Toggle whether a failed memcg charge should invoke the OOM killer
- * or just return -ENOMEM.  Returns the previous toggle state.
- *
- * NOTE: Any path that enables the OOM killer before charging must
- *       call mem_cgroup_oom_synchronize() afterward to finalize the
- *       OOM handling and clean up.
- */
-static inline bool mem_cgroup_toggle_oom(bool new)
+static inline void mem_cgroup_oom_enable(void)
 {
-       bool old;
-
-       old = current->memcg_oom.may_oom;
-       current->memcg_oom.may_oom = new;
-
-       return old;
+       WARN_ON(current->memcg_oom.may_oom);
+       current->memcg_oom.may_oom = 1;
 }
 
-static inline void mem_cgroup_enable_oom(void)
+static inline void mem_cgroup_oom_disable(void)
 {
-       bool old = mem_cgroup_toggle_oom(true);
-
-       WARN_ON(old == true);
-}
-
-static inline void mem_cgroup_disable_oom(void)
-{
-       bool old = mem_cgroup_toggle_oom(false);
-
-       WARN_ON(old == false);
+       WARN_ON(!current->memcg_oom.may_oom);
+       current->memcg_oom.may_oom = 0;
 }
 
 static inline bool task_in_memcg_oom(struct task_struct *p)
 {
-       return p->memcg_oom.in_memcg_oom;
+       return p->memcg_oom.memcg;
 }
 
-bool mem_cgroup_oom_synchronize(void);
+bool mem_cgroup_oom_synchronize(bool wait);
 
 #ifdef CONFIG_MEMCG_SWAP
 extern int do_swap_account;
@@ -402,16 +379,11 @@ static inline void mem_cgroup_end_update_page_stat(struct page *page,
 {
 }
 
-static inline bool mem_cgroup_toggle_oom(bool new)
-{
-       return false;
-}
-
-static inline void mem_cgroup_enable_oom(void)
+static inline void mem_cgroup_oom_enable(void)
 {
 }
 
-static inline void mem_cgroup_disable_oom(void)
+static inline void mem_cgroup_oom_disable(void)
 {
 }
 
@@ -420,7 +392,7 @@ static inline bool task_in_memcg_oom(struct task_struct *p)
        return false;
 }
 
-static inline bool mem_cgroup_oom_synchronize(void)
+static inline bool mem_cgroup_oom_synchronize(bool wait)
 {
        return false;
 }
index 41ed59276c002fc77b598ed60fb5fc68501e72c6..67c17b5a6f449cc760a28a621daf5f5ef0529586 100644 (file)
@@ -41,6 +41,13 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
                unsigned int mode, unsigned int channel,
                u8 ato, bool atox, unsigned int *sample);
 
+#define MC13783_AUDIO_RX0      36
+#define MC13783_AUDIO_RX1      37
+#define MC13783_AUDIO_TX       38
+#define MC13783_SSI_NETWORK    39
+#define MC13783_AUDIO_CODEC    40
+#define MC13783_AUDIO_DAC      41
+
 #define MC13XXX_IRQ_ADCDONE    0
 #define MC13XXX_IRQ_ADCBISDONE 1
 #define MC13XXX_IRQ_TS         2
index 68029b30c3dc89e2d2620fd41101b2ab05069344..5eb4e31af22b8e05356dfef793c1b96497af8cb3 100644 (file)
@@ -181,7 +181,7 @@ enum {
        MLX5_DEV_CAP_FLAG_TLP_HINTS     = 1LL << 39,
        MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40,
        MLX5_DEV_CAP_FLAG_DCT           = 1LL << 41,
-       MLX5_DEV_CAP_FLAG_CMDIF_CSUM    = 1LL << 46,
+       MLX5_DEV_CAP_FLAG_CMDIF_CSUM    = 3LL << 46,
 };
 
 enum {
@@ -417,7 +417,7 @@ struct mlx5_init_seg {
        struct health_buffer    health;
        __be32                  rsvd2[884];
        __be32                  health_counter;
-       __be32                  rsvd3[1023];
+       __be32                  rsvd3[1019];
        __be64                  ieee1588_clk;
        __be32                  ieee1588_clk_type;
        __be32                  clr_intx;
index 8888381fc150b8f3f852077407ee8187a54cb7aa..6b8c496572c841d8ec8be70740557f1caf50b79a 100644 (file)
@@ -82,7 +82,7 @@ enum {
 };
 
 enum {
-       MLX5_MAX_EQ_NAME        = 20
+       MLX5_MAX_EQ_NAME        = 32
 };
 
 enum {
@@ -747,8 +747,7 @@ static inline u32 mlx5_idx_to_mkey(u32 mkey_idx)
 
 enum {
        MLX5_PROF_MASK_QP_SIZE          = (u64)1 << 0,
-       MLX5_PROF_MASK_CMDIF_CSUM       = (u64)1 << 1,
-       MLX5_PROF_MASK_MR_CACHE         = (u64)1 << 2,
+       MLX5_PROF_MASK_MR_CACHE         = (u64)1 << 1,
 };
 
 enum {
@@ -758,7 +757,6 @@ enum {
 struct mlx5_profile {
        u64     mask;
        u32     log_max_qp;
-       int     cmdif_csum;
        struct {
                int     size;
                int     limit;
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
deleted file mode 100644 (file)
index c841282..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __OF_RESERVED_MEM_H
-#define __OF_RESERVED_MEM_H
-
-#ifdef CONFIG_OF_RESERVED_MEM
-void of_reserved_mem_device_init(struct device *dev);
-void of_reserved_mem_device_release(struct device *dev);
-void early_init_dt_scan_reserved_mem(void);
-#else
-static inline void of_reserved_mem_device_init(struct device *dev) { }
-static inline void of_reserved_mem_device_release(struct device *dev) { }
-static inline void early_init_dt_scan_reserved_mem(void) { }
-#endif
-
-#endif /* __OF_RESERVED_MEM_H */
index 8db5ae03b6e3f679c16988e492e8241f1567b2f5..689a856b86f90e1329515cf1ad9b80d3e2e7cdf5 100644 (file)
@@ -84,6 +84,8 @@ struct snd_platform_data {
        u8 version;
        u8 txnumevt;
        u8 rxnumevt;
+       int tx_dma_channel;
+       int rx_dma_channel;
 };
 
 enum {
index a10380bfbeac9b4c4d018c99a5c914d672833f04..dc90b8c134a12a9d5b87755a3e27fcfa7b01e0c8 100644 (file)
@@ -374,6 +374,7 @@ int regmap_reinit_cache(struct regmap *map,
                        const struct regmap_config *config);
 struct regmap *dev_get_regmap(struct device *dev, const char *name);
 int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
+int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
 int regmap_raw_write(struct regmap *map, unsigned int reg,
                     const void *val, size_t val_len);
 int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
@@ -387,9 +388,14 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
                     size_t val_count);
 int regmap_update_bits(struct regmap *map, unsigned int reg,
                       unsigned int mask, unsigned int val);
+int regmap_update_bits_async(struct regmap *map, unsigned int reg,
+                            unsigned int mask, unsigned int val);
 int regmap_update_bits_check(struct regmap *map, unsigned int reg,
                             unsigned int mask, unsigned int val,
                             bool *change);
+int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
+                                  unsigned int mask, unsigned int val,
+                                  bool *change);
 int regmap_get_val_bytes(struct regmap *map);
 int regmap_async_complete(struct regmap *map);
 bool regmap_can_raw_write(struct regmap *map);
@@ -425,11 +431,15 @@ bool regmap_reg_in_ranges(unsigned int reg,
  * @reg: Offset of the register within the regmap bank
  * @lsb: lsb of the register field.
  * @reg: msb of the register field.
+ * @id_size: port size if it has some ports
+ * @id_offset: address offset for each ports
  */
 struct reg_field {
        unsigned int reg;
        unsigned int lsb;
        unsigned int msb;
+       unsigned int id_size;
+       unsigned int id_offset;
 };
 
 #define REG_FIELD(_reg, _lsb, _msb) {          \
@@ -448,6 +458,15 @@ void devm_regmap_field_free(struct device *dev,    struct regmap_field *field);
 
 int regmap_field_read(struct regmap_field *field, unsigned int *val);
 int regmap_field_write(struct regmap_field *field, unsigned int val);
+int regmap_field_update_bits(struct regmap_field *field,
+                            unsigned int mask, unsigned int val);
+
+int regmap_fields_write(struct regmap_field *field, unsigned int id,
+                       unsigned int val);
+int regmap_fields_read(struct regmap_field *field, unsigned int id,
+                      unsigned int *val);
+int regmap_fields_update_bits(struct regmap_field *field,  unsigned int id,
+                             unsigned int mask, unsigned int val);
 
 /**
  * Description of an IRQ for the generic regmap irq_chip.
@@ -527,6 +546,13 @@ static inline int regmap_write(struct regmap *map, unsigned int reg,
        return -EINVAL;
 }
 
+static inline int regmap_write_async(struct regmap *map, unsigned int reg,
+                                    unsigned int val)
+{
+       WARN_ONCE(1, "regmap API is disabled");
+       return -EINVAL;
+}
+
 static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
                                   const void *val, size_t val_len)
 {
@@ -576,6 +602,14 @@ static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
        return -EINVAL;
 }
 
+static inline int regmap_update_bits_async(struct regmap *map,
+                                          unsigned int reg,
+                                          unsigned int mask, unsigned int val)
+{
+       WARN_ONCE(1, "regmap API is disabled");
+       return -EINVAL;
+}
+
 static inline int regmap_update_bits_check(struct regmap *map,
                                           unsigned int reg,
                                           unsigned int mask, unsigned int val,
@@ -585,6 +619,16 @@ static inline int regmap_update_bits_check(struct regmap *map,
        return -EINVAL;
 }
 
+static inline int regmap_update_bits_check_async(struct regmap *map,
+                                                unsigned int reg,
+                                                unsigned int mask,
+                                                unsigned int val,
+                                                bool *change)
+{
+       WARN_ONCE(1, "regmap API is disabled");
+       return -EINVAL;
+}
+
 static inline int regmap_get_val_bytes(struct regmap *map)
 {
        WARN_ONCE(1, "regmap API is disabled");
index 6682da36b293cfad598a0c5803e9e32038f72aa3..e27baeeda3f470ed99ae899d8de22da062856bf8 100644 (file)
@@ -1394,11 +1394,10 @@ struct task_struct {
        } memcg_batch;
        unsigned int memcg_kmem_skip_account;
        struct memcg_oom_info {
+               struct mem_cgroup *memcg;
+               gfp_t gfp_mask;
+               int order;
                unsigned int may_oom:1;
-               unsigned int in_memcg_oom:1;
-               unsigned int oom_locked:1;
-               int wakeups;
-               struct mem_cgroup *wait_on_memcg;
        } memcg_oom;
 #endif
 #ifdef CONFIG_UPROBES
diff --git a/include/linux/thinkpad_acpi.h b/include/linux/thinkpad_acpi.h
new file mode 100644 (file)
index 0000000..361de59
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __THINKPAD_ACPI_H__
+#define __THINKPAD_ACPI_H__
+
+/* These two functions return 0 if success, or negative error code
+   (e g -ENODEV if no led present) */
+
+enum {
+       TPACPI_LED_MUTE,
+       TPACPI_LED_MICMUTE,
+       TPACPI_LED_MAX,
+};
+
+int tpacpi_led_set(int whichled, bool on);
+
+#endif
index f9a7e7bc925be61322a24304076503bd918a520a..11d85b9c1b081af6a9f4f30ac3c1458766ed4238 100644 (file)
@@ -12,7 +12,7 @@ struct usb_phy_gen_xceiv_platform_data {
        unsigned int needs_reset:1;
 };
 
-#if IS_ENABLED(CONFIG_NOP_USB_XCEIV)
+#if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE))
 /* sometimes transceivers are accessed only through e.g. ULPI */
 extern void usb_nop_xceiv_register(void);
 extern void usb_nop_xceiv_unregister(void);
index bf99cd01be206ebeb170d826e176c3ac22e1493e..630356866030d88a355390a932105ff9c86b98bb 100644 (file)
@@ -66,7 +66,9 @@
        US_FLAG(INITIAL_READ10, 0x00100000)                     \
                /* Initial READ(10) (and others) must be retried */     \
        US_FLAG(WRITE_CACHE,    0x00200000)                     \
-               /* Write Cache status is not available */
+               /* Write Cache status is not available */       \
+       US_FLAG(NEEDS_CAP16,    0x00400000)
+               /* cannot handle READ_CAPACITY_10 */
 
 #define US_FLAG(name, value)   US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
index 9031a26249b56e1bcc1fde74bde36a5f50dfe463..175ab3237b58cde2fe07b12d2aede5d05d9a0359 100644 (file)
@@ -48,6 +48,8 @@ struct snd_compr_ops;
  *     the ring buffer
  * @total_bytes_transferred: cumulative bytes transferred by offload DSP
  * @sleep: poll sleep
+ * @wait: drain wait queue
+ * @drain_wake: condition for drain wake
  */
 struct snd_compr_runtime {
        snd_pcm_state_t state;
@@ -59,6 +61,8 @@ struct snd_compr_runtime {
        u64 total_bytes_available;
        u64 total_bytes_transferred;
        wait_queue_head_t sleep;
+       wait_queue_head_t wait;
+       unsigned int drain_wake;
        void *private_data;
 };
 
@@ -171,4 +175,12 @@ static inline void snd_compr_fragment_elapsed(struct snd_compr_stream *stream)
        wake_up(&stream->runtime->sleep);
 }
 
+static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
+{
+       snd_BUG_ON(!stream);
+
+       stream->runtime->drain_wake = 1;
+       wake_up(&stream->runtime->wait);
+}
+
 #endif
diff --git a/include/sound/cs42l73.h b/include/sound/cs42l73.h
new file mode 100644 (file)
index 0000000..f354be4
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * linux/sound/cs42l73.h -- Platform data for CS42L73
+ *
+ * Copyright (c) 2012 Cirrus Logic Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __CS42L73_H
+#define __CS42L73_H
+
+struct cs42l73_platform_data {
+       /* RST GPIO */
+       unsigned int reset_gpio;
+       unsigned int chgfreq;
+       int jack_detection;
+       unsigned int mclk_freq;
+};
+
+#endif /* __CS42L73_H */
index f11c35cd5532df9d549bee84fa4d414837ccc2b3..15017311f2e9f0c9c2dba9bf41c00f01763cee0f 100644 (file)
@@ -61,6 +61,8 @@ struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream)
  * @slave_id: Slave requester id for the DMA channel.
  * @filter_data: Custom DMA channel filter data, this will usually be used when
  * requesting the DMA channel.
+ * @chan_name: Custom channel name to use when requesting DMA channel.
+ * @fifo_size: FIFO size of the DAI controller in bytes
  */
 struct snd_dmaengine_dai_dma_data {
        dma_addr_t addr;
@@ -68,6 +70,8 @@ struct snd_dmaengine_dai_dma_data {
        u32 maxburst;
        unsigned int slave_id;
        void *filter_data;
+       const char *chan_name;
+       unsigned int fifo_size;
 };
 
 void snd_dmaengine_pcm_set_config_from_dai_data(
@@ -96,6 +100,10 @@ void snd_dmaengine_pcm_set_config_from_dai_data(
  * playback.
  */
 #define SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX BIT(3)
+/*
+ * The PCM streams have custom channel names specified.
+ */
+#define SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME BIT(4)
 
 /**
  * struct snd_dmaengine_pcm_config - Configuration data for dmaengine based PCM
index cf15b8213df7e0bd7e25e6d003f23ffd1d375674..af998397041768a82ee347665e7040a9a4e44b9c 100644 (file)
@@ -52,6 +52,11 @@ struct snd_dma_device {
 #else
 #define SNDRV_DMA_TYPE_DEV_SG  SNDRV_DMA_TYPE_DEV /* no SG-buf support */
 #endif
+#ifdef CONFIG_GENERIC_ALLOCATOR
+#define SNDRV_DMA_TYPE_DEV_IRAM                4       /* generic device iram-buffer */
+#else
+#define SNDRV_DMA_TYPE_DEV_IRAM        SNDRV_DMA_TYPE_DEV
+#endif
 
 /*
  * info for buffer allocation
index fb0a312bcb810c93622028ef93934d3779189142..12afab18945d056709df7495b75b0da6c0155426 100644 (file)
@@ -36,7 +36,6 @@
 #define RSND_SSI_CLK_PIN_SHARE         (1 << 31)
 #define RSND_SSI_CLK_FROM_ADG          (1 << 30) /* clock parent is master */
 #define RSND_SSI_SYNC                  (1 << 29) /* SSI34_sync etc */
-#define RSND_SSI_DEPENDENT             (1 << 28) /* SSI needs SRU/SCU */
 
 #define RSND_SSI_PLAY                  (1 << 24)
 
index ae9a227d35d3538c233b2b1cb777afcbcb4e639d..800c101bb096fd6f5c1170ebbdce1ab06cead062 100644 (file)
@@ -105,6 +105,8 @@ int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
 int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
        int pll_id, int source, unsigned int freq_in, unsigned int freq_out);
 
+int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio);
+
 /* Digital Audio interface formatting */
 int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
 
@@ -131,6 +133,7 @@ struct snd_soc_dai_ops {
        int (*set_pll)(struct snd_soc_dai *dai, int pll_id, int source,
                unsigned int freq_in, unsigned int freq_out);
        int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
+       int (*set_bclk_ratio)(struct snd_soc_dai *dai, unsigned int ratio);
 
        /*
         * DAI format configuration
@@ -166,6 +169,13 @@ struct snd_soc_dai_ops {
                struct snd_soc_dai *);
        int (*prepare)(struct snd_pcm_substream *,
                struct snd_soc_dai *);
+       /*
+        * NOTE: Commands passed to the trigger function are not necessarily
+        * compatible with the current state of the dai. For example this
+        * sequence of commands is possible: START STOP STOP.
+        * So do not unconditionally use refcounting functions in the trigger
+        * function, e.g. clk_enable/disable.
+        */
        int (*trigger)(struct snd_pcm_substream *, int,
                struct snd_soc_dai *);
        int (*bespoke_trigger)(struct snd_pcm_substream *, int,
@@ -276,6 +286,13 @@ static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai,
                dai->capture_dma_data = data;
 }
 
+static inline void snd_soc_dai_init_dma_data(struct snd_soc_dai *dai,
+                                            void *playback, void *capture)
+{
+       dai->playback_dma_data = playback;
+       dai->capture_dma_data = capture;
+}
+
 static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai,
                void *data)
 {
index 27a72d5d4b00ff36133fb19a2a1580044ac27d11..2037c45adfe648e907fa86290f7dfea847989c20 100644 (file)
@@ -286,6 +286,8 @@ struct device;
        .info = snd_soc_info_volsw, \
        .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
        .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) }
+#define SOC_DAPM_SINGLE_VIRT(xname, max) \
+       SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0)
 #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
        .info = snd_soc_info_volsw, \
@@ -300,6 +302,8 @@ struct device;
        .tlv.p = (tlv_array), \
        .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
        .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
+#define SOC_DAPM_SINGLE_TLV_VIRT(xname, max, tlv_array) \
+       SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0, tlv_array)
 #define SOC_DAPM_ENUM(xname, xenum) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
        .info = snd_soc_info_enum_double, \
index d22cb0a06feb36949476ac8c761e3f1c0efa671c..1f741cb24f337c3e4662c2ff2cd45f78985c54c1 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef __LINUX_SND_SOC_H
 #define __LINUX_SND_SOC_H
 
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
 #include <linux/notifier.h>
@@ -330,7 +331,6 @@ struct soc_enum;
 struct snd_soc_jack;
 struct snd_soc_jack_zone;
 struct snd_soc_jack_pin;
-struct snd_soc_cache_ops;
 #include <sound/soc-dapm.h>
 #include <sound/soc-dpcm.h>
 
@@ -348,10 +348,6 @@ enum snd_soc_control_type {
        SND_SOC_REGMAP,
 };
 
-enum snd_soc_compress_type {
-       SND_SOC_FLAT_COMPRESSION = 1,
-};
-
 enum snd_soc_pcm_subclass {
        SND_SOC_PCM_CLASS_PCM   = 0,
        SND_SOC_PCM_CLASS_BE    = 1,
@@ -369,6 +365,7 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
 
 int snd_soc_register_card(struct snd_soc_card *card);
 int snd_soc_unregister_card(struct snd_soc_card *card);
+int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
 int snd_soc_suspend(struct device *dev);
 int snd_soc_resume(struct device *dev);
 int snd_soc_poweroff(struct device *dev);
@@ -386,6 +383,9 @@ void snd_soc_unregister_codec(struct device *dev);
 int snd_soc_register_component(struct device *dev,
                         const struct snd_soc_component_driver *cmpnt_drv,
                         struct snd_soc_dai_driver *dai_drv, int num_dai);
+int devm_snd_soc_register_component(struct device *dev,
+                        const struct snd_soc_component_driver *cmpnt_drv,
+                        struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_component(struct device *dev);
 int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
                                    unsigned int reg);
@@ -403,12 +403,6 @@ int snd_soc_cache_write(struct snd_soc_codec *codec,
                        unsigned int reg, unsigned int value);
 int snd_soc_cache_read(struct snd_soc_codec *codec,
                       unsigned int reg, unsigned int *value);
-int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
-                                     unsigned int reg);
-int snd_soc_default_readable_register(struct snd_soc_codec *codec,
-                                     unsigned int reg);
-int snd_soc_default_writable_register(struct snd_soc_codec *codec,
-                                     unsigned int reg);
 int snd_soc_platform_read(struct snd_soc_platform *platform,
                                        unsigned int reg);
 int snd_soc_platform_write(struct snd_soc_platform *platform,
@@ -541,22 +535,6 @@ int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
 int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol);
 
-/**
- * struct snd_soc_reg_access - Describes whether a given register is
- * readable, writable or volatile.
- *
- * @reg: the register number
- * @read: whether this register is readable
- * @write: whether this register is writable
- * @vol: whether this register is volatile
- */
-struct snd_soc_reg_access {
-       u16 reg;
-       u16 read;
-       u16 write;
-       u16 vol;
-};
-
 /**
  * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
  *
@@ -657,17 +635,26 @@ struct snd_soc_compr_ops {
        int (*trigger)(struct snd_compr_stream *);
 };
 
-/* SoC cache ops */
-struct snd_soc_cache_ops {
+/* component interface */
+struct snd_soc_component_driver {
+       const char *name;
+
+       /* DT */
+       int (*of_xlate_dai_name)(struct snd_soc_component *component,
+                                struct of_phandle_args *args,
+                                const char **dai_name);
+};
+
+struct snd_soc_component {
        const char *name;
-       enum snd_soc_compress_type id;
-       int (*init)(struct snd_soc_codec *codec);
-       int (*exit)(struct snd_soc_codec *codec);
-       int (*read)(struct snd_soc_codec *codec, unsigned int reg,
-               unsigned int *value);
-       int (*write)(struct snd_soc_codec *codec, unsigned int reg,
-               unsigned int value);
-       int (*sync)(struct snd_soc_codec *codec);
+       int id;
+       struct device *dev;
+       struct list_head list;
+
+       struct snd_soc_dai_driver *dai_drv;
+       int num_dai;
+
+       const struct snd_soc_component_driver *driver;
 };
 
 /* SoC Audio Codec device */
@@ -683,8 +670,6 @@ struct snd_soc_codec {
        struct list_head list;
        struct list_head card_list;
        int num_dai;
-       enum snd_soc_compress_type compress_type;
-       size_t reg_size;        /* reg_cache_size * reg_word_size */
        int (*volatile_register)(struct snd_soc_codec *, unsigned int);
        int (*readable_register)(struct snd_soc_codec *, unsigned int);
        int (*writable_register)(struct snd_soc_codec *, unsigned int);
@@ -708,13 +693,13 @@ struct snd_soc_codec {
        unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
        unsigned int (*read)(struct snd_soc_codec *, unsigned int);
        int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
-       int (*bulk_write_raw)(struct snd_soc_codec *, unsigned int, const void *, size_t);
        void *reg_cache;
-       const void *reg_def_copy;
-       const struct snd_soc_cache_ops *cache_ops;
        struct mutex cache_rw_mutex;
        int val_bytes;
 
+       /* component */
+       struct snd_soc_component component;
+
        /* dapm */
        struct snd_soc_dapm_context dapm;
        unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
@@ -733,6 +718,7 @@ struct snd_soc_codec_driver {
        int (*remove)(struct snd_soc_codec *);
        int (*suspend)(struct snd_soc_codec *);
        int (*resume)(struct snd_soc_codec *);
+       struct snd_soc_component_driver component_driver;
 
        /* Default control and setup, added after probe() is run */
        const struct snd_kcontrol_new *controls;
@@ -760,9 +746,6 @@ struct snd_soc_codec_driver {
        short reg_cache_step;
        short reg_word_size;
        const void *reg_cache_default;
-       short reg_access_size;
-       const struct snd_soc_reg_access *reg_access_default;
-       enum snd_soc_compress_type compress_type;
 
        /* codec bias level */
        int (*set_bias_level)(struct snd_soc_codec *,
@@ -849,20 +832,6 @@ struct snd_soc_platform {
 #endif
 };
 
-struct snd_soc_component_driver {
-       const char *name;
-};
-
-struct snd_soc_component {
-       const char *name;
-       int id;
-       int num_dai;
-       struct device *dev;
-       struct list_head list;
-
-       const struct snd_soc_component_driver *driver;
-};
-
 struct snd_soc_dai_link {
        /* config - must be set by machine driver */
        const char *name;                       /* Codec name */
@@ -944,12 +913,6 @@ struct snd_soc_codec_conf {
         * associated per device
         */
        const char *name_prefix;
-
-       /*
-        * set this to the desired compression type if you want to
-        * override the one supplied in codec->driver->compress_type
-        */
-       enum snd_soc_compress_type compress_type;
 };
 
 struct snd_soc_aux_dev {
@@ -1088,7 +1051,8 @@ struct snd_soc_pcm_runtime {
 /* mixer control */
 struct soc_mixer_control {
        int min, max, platform_max;
-       unsigned int reg, rreg, shift, rshift;
+       int reg, rreg;
+       unsigned int shift, rshift;
        unsigned int invert:1;
        unsigned int autodisable:1;
 };
@@ -1121,8 +1085,6 @@ struct soc_enum {
 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
 unsigned int snd_soc_write(struct snd_soc_codec *codec,
                           unsigned int reg, unsigned int val);
-unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec,
-                                   unsigned int reg, const void *data, size_t len);
 
 /* device driver data */
 
@@ -1201,6 +1163,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
                                   const char *propname);
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
                                     const char *prefix);
+int snd_soc_of_get_dai_name(struct device_node *of_node,
+                           const char **dai_name);
 
 #include <sound/soc-dai.h>
 
index 5fc2dcdd21cddcadc15daa9dc3e62dde7b41b5d2..03996b2bb04f86bcb4cea7c1aab4971b2d4c310d 100644 (file)
@@ -14,6 +14,7 @@ struct snd_soc_codec;
 struct snd_soc_platform;
 struct snd_soc_card;
 struct snd_soc_dapm_widget;
+struct snd_soc_dapm_path;
 
 /*
  * Log register events
index 0f7d279ebde35fd1be21cc922def324eaacb240f..a7f27704f9807e7b14eadb9b08cf09c2c183a6a7 100644 (file)
@@ -5,6 +5,7 @@ header-y += asound_fm.h
 header-y += compress_offload.h
 header-y += compress_params.h
 header-y += emu10k1.h
+header-y += firewire.h
 header-y += hdsp.h
 header-y += hdspm.h
 header-y += sb16_csp.h
index 041203f20f6d1cb3cac42df78723356550729054..9fc6219d38482cd3dc8a34f8653d24dfeee2a792 100644 (file)
@@ -93,9 +93,10 @@ enum {
        SNDRV_HWDEP_IFACE_SB_RC,        /* SB Extigy/Audigy2NX remote control */
        SNDRV_HWDEP_IFACE_HDA,          /* HD-audio */
        SNDRV_HWDEP_IFACE_USB_STREAM,   /* direct access to usb stream */
+       SNDRV_HWDEP_IFACE_FW_DICE,      /* TC DICE FireWire device */
 
        /* Don't forget to change the following: */
-       SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USB_STREAM
+       SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_FW_DICE
 };
 
 struct snd_hwdep_info {
diff --git a/include/uapi/sound/firewire.h b/include/uapi/sound/firewire.h
new file mode 100644 (file)
index 0000000..e86131c
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef UAPI_SOUND_FIREWIRE_H_INCLUDED
+#define UAPI_SOUND_FIREWIRE_H_INCLUDED
+
+#include <linux/ioctl.h>
+
+/* events can be read() from the hwdep device */
+
+#define SNDRV_FIREWIRE_EVENT_LOCK_STATUS       0x000010cc
+#define SNDRV_FIREWIRE_EVENT_DICE_NOTIFICATION 0xd1ce004e
+
+struct snd_firewire_event_common {
+       unsigned int type; /* SNDRV_FIREWIRE_EVENT_xxx */
+};
+
+struct snd_firewire_event_lock_status {
+       unsigned int type;
+       unsigned int status; /* 0/1 = unlocked/locked */
+};
+
+struct snd_firewire_event_dice_notification {
+       unsigned int type;
+       unsigned int notification; /* DICE-specific bits */
+};
+
+union snd_firewire_event {
+       struct snd_firewire_event_common            common;
+       struct snd_firewire_event_lock_status       lock_status;
+       struct snd_firewire_event_dice_notification dice_notification;
+};
+
+
+#define SNDRV_FIREWIRE_IOCTL_GET_INFO _IOR('H', 0xf8, struct snd_firewire_get_info)
+#define SNDRV_FIREWIRE_IOCTL_LOCK      _IO('H', 0xf9)
+#define SNDRV_FIREWIRE_IOCTL_UNLOCK    _IO('H', 0xfa)
+
+#define SNDRV_FIREWIRE_TYPE_DICE       1
+/* Fireworks, AV/C, RME, MOTU, ... */
+
+struct snd_firewire_get_info {
+       unsigned int type; /* SNDRV_FIREWIRE_TYPE_xxx */
+       unsigned int card; /* same as fw_cdev_get_info.card */
+       unsigned char guid[8];
+       char device_name[16]; /* device node in /dev */
+};
+
+/*
+ * SNDRV_FIREWIRE_IOCTL_LOCK prevents the driver from streaming.
+ * Returns -EBUSY if the driver is already streaming.
+ */
+
+#endif
index 8c4f59b0204a2821811a4b28fd48e0ce6163d987..db9d241af133d770cb0a95a22cacf257f79b1215 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1282,6 +1282,12 @@ static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum,
 
        sem_lock(sma, NULL, -1);
 
+       if (sma->sem_perm.deleted) {
+               sem_unlock(sma, -1);
+               rcu_read_unlock();
+               return -EIDRM;
+       }
+
        curr = &sma->sem_base[semnum];
 
        ipc_assert_locked_object(&sma->sem_perm);
@@ -1336,12 +1342,14 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                int i;
 
                sem_lock(sma, NULL, -1);
+               if (sma->sem_perm.deleted) {
+                       err = -EIDRM;
+                       goto out_unlock;
+               }
                if(nsems > SEMMSL_FAST) {
                        if (!ipc_rcu_getref(sma)) {
-                               sem_unlock(sma, -1);
-                               rcu_read_unlock();
                                err = -EIDRM;
-                               goto out_free;
+                               goto out_unlock;
                        }
                        sem_unlock(sma, -1);
                        rcu_read_unlock();
@@ -1354,10 +1362,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                        rcu_read_lock();
                        sem_lock_and_putref(sma);
                        if (sma->sem_perm.deleted) {
-                               sem_unlock(sma, -1);
-                               rcu_read_unlock();
                                err = -EIDRM;
-                               goto out_free;
+                               goto out_unlock;
                        }
                }
                for (i = 0; i < sma->sem_nsems; i++)
@@ -1375,8 +1381,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                struct sem_undo *un;
 
                if (!ipc_rcu_getref(sma)) {
-                       rcu_read_unlock();
-                       return -EIDRM;
+                       err = -EIDRM;
+                       goto out_rcu_wakeup;
                }
                rcu_read_unlock();
 
@@ -1404,10 +1410,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                rcu_read_lock();
                sem_lock_and_putref(sma);
                if (sma->sem_perm.deleted) {
-                       sem_unlock(sma, -1);
-                       rcu_read_unlock();
                        err = -EIDRM;
-                       goto out_free;
+                       goto out_unlock;
                }
 
                for (i = 0; i < nsems; i++)
@@ -1431,6 +1435,10 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                goto out_rcu_wakeup;
 
        sem_lock(sma, NULL, -1);
+       if (sma->sem_perm.deleted) {
+               err = -EIDRM;
+               goto out_unlock;
+       }
        curr = &sma->sem_base[semnum];
 
        switch (cmd) {
@@ -1836,6 +1844,10 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
        if (error)
                goto out_rcu_wakeup;
 
+       error = -EIDRM;
+       locknum = sem_lock(sma, sops, nsops);
+       if (sma->sem_perm.deleted)
+               goto out_unlock_free;
        /*
         * semid identifiers are not unique - find_alloc_undo may have
         * allocated an undo structure, it was invalidated by an RMID
@@ -1843,8 +1855,6 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
         * This case can be detected checking un->semid. The existence of
         * "un" itself is guaranteed by rcu.
         */
-       error = -EIDRM;
-       locknum = sem_lock(sma, sops, nsops);
        if (un && un->semid == -1)
                goto out_unlock_free;
 
@@ -2057,6 +2067,12 @@ void exit_sem(struct task_struct *tsk)
                }
 
                sem_lock(sma, NULL, -1);
+               /* exit_sem raced with IPC_RMID, nothing to do */
+               if (sma->sem_perm.deleted) {
+                       sem_unlock(sma, -1);
+                       rcu_read_unlock();
+                       continue;
+               }
                un = __lookup_undo(ulp, semid);
                if (un == NULL) {
                        /* exit_sem raced with IPC_RMID+semget() that created
index fdb8ae7407755f9b1c3725e2a7fd38a8a31c7f54..7684f41bce76a9b430f04b7e4e77810b48798a42 100644 (file)
  *            Pavel Emelianov <xemul@openvz.org>
  *
  * General sysv ipc locking scheme:
- *  when doing ipc id lookups, take the ids->rwsem
- *      rcu_read_lock()
- *          obtain the ipc object (kern_ipc_perm)
- *          perform security, capabilities, auditing and permission checks, etc.
- *          acquire the ipc lock (kern_ipc_perm.lock) throught ipc_lock_object()
- *             perform data updates (ie: SET, RMID, LOCK/UNLOCK commands)
+ *     rcu_read_lock()
+ *          obtain the ipc object (kern_ipc_perm) by looking up the id in an idr
+ *         tree.
+ *         - perform initial checks (capabilities, auditing and permission,
+ *           etc).
+ *         - perform read-only operations, such as STAT, INFO commands.
+ *           acquire the ipc lock (kern_ipc_perm.lock) through
+ *           ipc_lock_object()
+ *             - perform data updates, such as SET, RMID commands and
+ *               mechanism-specific operations (semop/semtimedop,
+ *               msgsnd/msgrcv, shmat/shmdt).
+ *         drop the ipc lock, through ipc_unlock_object().
+ *     rcu_read_unlock()
+ *
+ *  The ids->rwsem must be taken when:
+ *     - creating, removing and iterating the existing entries in ipc
+ *       identifier sets.
+ *     - iterating through files under /proc/sysvipc/
+ *
+ *  Note that sems have a special fast path that avoids kern_ipc_perm.lock -
+ *  see sem_lock().
  */
 
 #include <linux/mm.h>
index 7deeb6297a483d7272acb30c4f3b0c0d6b0e76b3..1a53d497a8c53ae460686af6107531c4161eae53 100644 (file)
@@ -53,6 +53,7 @@ int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release)
        ref->release = release;
        return 0;
 }
+EXPORT_SYMBOL_GPL(percpu_ref_init);
 
 /**
  * percpu_ref_cancel_init - cancel percpu_ref_init()
@@ -84,6 +85,7 @@ void percpu_ref_cancel_init(struct percpu_ref *ref)
                free_percpu(ref->pcpu_count);
        }
 }
+EXPORT_SYMBOL_GPL(percpu_ref_cancel_init);
 
 static void percpu_ref_kill_rcu(struct rcu_head *rcu)
 {
@@ -156,3 +158,4 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref,
 
        call_rcu_sched(&ref->rcu, percpu_ref_kill_rcu);
 }
+EXPORT_SYMBOL_GPL(percpu_ref_kill_and_confirm);
index 1e6aec4a2d2ebae29c0fea0405a7e81f422beeb4..ae4846ff48494e9ac5e733a5d5339b61763a49f5 100644 (file)
@@ -1616,7 +1616,6 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        struct inode *inode = mapping->host;
        pgoff_t offset = vmf->pgoff;
        struct page *page;
-       bool memcg_oom;
        pgoff_t size;
        int ret = 0;
 
@@ -1625,11 +1624,7 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
                return VM_FAULT_SIGBUS;
 
        /*
-        * Do we have something in the page cache already?  Either
-        * way, try readahead, but disable the memcg OOM killer for it
-        * as readahead is optional and no errors are propagated up
-        * the fault stack.  The OOM killer is enabled while trying to
-        * instantiate the faulting page individually below.
+        * Do we have something in the page cache already?
         */
        page = find_get_page(mapping, offset);
        if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) {
@@ -1637,14 +1632,10 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
                 * We found the page, so try async readahead before
                 * waiting for the lock.
                 */
-               memcg_oom = mem_cgroup_toggle_oom(false);
                do_async_mmap_readahead(vma, ra, file, page, offset);
-               mem_cgroup_toggle_oom(memcg_oom);
        } else if (!page) {
                /* No page in the page cache at all */
-               memcg_oom = mem_cgroup_toggle_oom(false);
                do_sync_mmap_readahead(vma, ra, file, offset);
-               mem_cgroup_toggle_oom(memcg_oom);
                count_vm_event(PGMAJFAULT);
                mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT);
                ret = VM_FAULT_MAJOR;
index 7489884682d84a6b5840fef19e90234076fd374e..610e3df2768a6a5b2ec1e293da4c96dafbbe2d30 100644 (file)
@@ -2697,6 +2697,7 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address,
 
        mmun_start = haddr;
        mmun_end   = haddr + HPAGE_PMD_SIZE;
+again:
        mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
        spin_lock(&mm->page_table_lock);
        if (unlikely(!pmd_trans_huge(*pmd))) {
@@ -2719,7 +2720,14 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address,
        split_huge_page(page);
 
        put_page(page);
-       BUG_ON(pmd_trans_huge(*pmd));
+
+       /*
+        * We don't always have down_write of mmap_sem here: a racing
+        * do_huge_pmd_wp_page() might have copied-on-write to another
+        * huge page before our split_huge_page() got the anon_vma lock.
+        */
+       if (unlikely(pmd_trans_huge(*pmd)))
+               goto again;
 }
 
 void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address,
index b49579c7f2a550462c334f97907f2fc131a65e00..0b7656e804d126cf0fcfa04a8b427396af86deb1 100644 (file)
@@ -653,6 +653,7 @@ static void free_huge_page(struct page *page)
        BUG_ON(page_count(page));
        BUG_ON(page_mapcount(page));
        restore_reserve = PagePrivate(page);
+       ClearPagePrivate(page);
 
        spin_lock(&hugetlb_lock);
        hugetlb_cgroup_uncharge_page(hstate_index(h),
@@ -695,8 +696,22 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order)
        /* we rely on prep_new_huge_page to set the destructor */
        set_compound_order(page, order);
        __SetPageHead(page);
+       __ClearPageReserved(page);
        for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) {
                __SetPageTail(p);
+               /*
+                * For gigantic hugepages allocated through bootmem at
+                * boot, it's safer to be consistent with the not-gigantic
+                * hugepages and clear the PG_reserved bit from all tail pages
+                * too.  Otherwse drivers using get_user_pages() to access tail
+                * pages may get the reference counting wrong if they see
+                * PG_reserved set on a tail page (despite the head page not
+                * having PG_reserved set).  Enforcing this consistency between
+                * head and tail pages allows drivers to optimize away a check
+                * on the head page when they need know if put_page() is needed
+                * after get_user_pages().
+                */
+               __ClearPageReserved(p);
                set_page_count(p, 0);
                p->first_page = page;
        }
@@ -1329,9 +1344,9 @@ static void __init gather_bootmem_prealloc(void)
 #else
                page = virt_to_page(m);
 #endif
-               __ClearPageReserved(page);
                WARN_ON(page_count(page) != 1);
                prep_compound_huge_page(page, h->order);
+               WARN_ON(PageReserved(page));
                prep_new_huge_page(h, page, page_to_nid(page));
                /*
                 * If we had gigantic hugepages allocated at boot time, we need
index 1c52ddbc839ba1f8f42e940c51bc321ba6b2abfe..34d3ca9572d6baed85499d099a0050af3b9bdf66 100644 (file)
@@ -866,6 +866,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg,
        unsigned long val = 0;
        int cpu;
 
+       get_online_cpus();
        for_each_online_cpu(cpu)
                val += per_cpu(memcg->stat->events[idx], cpu);
 #ifdef CONFIG_HOTPLUG_CPU
@@ -873,6 +874,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg,
        val += memcg->nocpu_base.events[idx];
        spin_unlock(&memcg->pcp_counter_lock);
 #endif
+       put_online_cpus();
        return val;
 }
 
@@ -2159,110 +2161,59 @@ static void memcg_oom_recover(struct mem_cgroup *memcg)
                memcg_wakeup_oom(memcg);
 }
 
-/*
- * try to call OOM killer
- */
 static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order)
 {
-       bool locked;
-       int wakeups;
-
        if (!current->memcg_oom.may_oom)
                return;
-
-       current->memcg_oom.in_memcg_oom = 1;
-
        /*
-        * As with any blocking lock, a contender needs to start
-        * listening for wakeups before attempting the trylock,
-        * otherwise it can miss the wakeup from the unlock and sleep
-        * indefinitely.  This is just open-coded because our locking
-        * is so particular to memcg hierarchies.
+        * We are in the middle of the charge context here, so we
+        * don't want to block when potentially sitting on a callstack
+        * that holds all kinds of filesystem and mm locks.
+        *
+        * Also, the caller may handle a failed allocation gracefully
+        * (like optional page cache readahead) and so an OOM killer
+        * invocation might not even be necessary.
+        *
+        * That's why we don't do anything here except remember the
+        * OOM context and then deal with it at the end of the page
+        * fault when the stack is unwound, the locks are released,
+        * and when we know whether the fault was overall successful.
         */
-       wakeups = atomic_read(&memcg->oom_wakeups);
-       mem_cgroup_mark_under_oom(memcg);
-
-       locked = mem_cgroup_oom_trylock(memcg);
-
-       if (locked)
-               mem_cgroup_oom_notify(memcg);
-
-       if (locked && !memcg->oom_kill_disable) {
-               mem_cgroup_unmark_under_oom(memcg);
-               mem_cgroup_out_of_memory(memcg, mask, order);
-               mem_cgroup_oom_unlock(memcg);
-               /*
-                * There is no guarantee that an OOM-lock contender
-                * sees the wakeups triggered by the OOM kill
-                * uncharges.  Wake any sleepers explicitely.
-                */
-               memcg_oom_recover(memcg);
-       } else {
-               /*
-                * A system call can just return -ENOMEM, but if this
-                * is a page fault and somebody else is handling the
-                * OOM already, we need to sleep on the OOM waitqueue
-                * for this memcg until the situation is resolved.
-                * Which can take some time because it might be
-                * handled by a userspace task.
-                *
-                * However, this is the charge context, which means
-                * that we may sit on a large call stack and hold
-                * various filesystem locks, the mmap_sem etc. and we
-                * don't want the OOM handler to deadlock on them
-                * while we sit here and wait.  Store the current OOM
-                * context in the task_struct, then return -ENOMEM.
-                * At the end of the page fault handler, with the
-                * stack unwound, pagefault_out_of_memory() will check
-                * back with us by calling
-                * mem_cgroup_oom_synchronize(), possibly putting the
-                * task to sleep.
-                */
-               current->memcg_oom.oom_locked = locked;
-               current->memcg_oom.wakeups = wakeups;
-               css_get(&memcg->css);
-               current->memcg_oom.wait_on_memcg = memcg;
-       }
+       css_get(&memcg->css);
+       current->memcg_oom.memcg = memcg;
+       current->memcg_oom.gfp_mask = mask;
+       current->memcg_oom.order = order;
 }
 
 /**
  * mem_cgroup_oom_synchronize - complete memcg OOM handling
+ * @handle: actually kill/wait or just clean up the OOM state
  *
- * This has to be called at the end of a page fault if the the memcg
- * OOM handler was enabled and the fault is returning %VM_FAULT_OOM.
+ * This has to be called at the end of a page fault if the memcg OOM
+ * handler was enabled.
  *
- * Memcg supports userspace OOM handling, so failed allocations must
+ * Memcg supports userspace OOM handling where failed allocations must
  * sleep on a waitqueue until the userspace task resolves the
  * situation.  Sleeping directly in the charge context with all kinds
  * of locks held is not a good idea, instead we remember an OOM state
  * in the task and mem_cgroup_oom_synchronize() has to be called at
- * the end of the page fault to put the task to sleep and clean up the
- * OOM state.
+ * the end of the page fault to complete the OOM handling.
  *
  * Returns %true if an ongoing memcg OOM situation was detected and
- * finalized, %false otherwise.
+ * completed, %false otherwise.
  */
-bool mem_cgroup_oom_synchronize(void)
+bool mem_cgroup_oom_synchronize(bool handle)
 {
+       struct mem_cgroup *memcg = current->memcg_oom.memcg;
        struct oom_wait_info owait;
-       struct mem_cgroup *memcg;
+       bool locked;
 
        /* OOM is global, do not handle */
-       if (!current->memcg_oom.in_memcg_oom)
-               return false;
-
-       /*
-        * We invoked the OOM killer but there is a chance that a kill
-        * did not free up any charges.  Everybody else might already
-        * be sleeping, so restart the fault and keep the rampage
-        * going until some charges are released.
-        */
-       memcg = current->memcg_oom.wait_on_memcg;
        if (!memcg)
-               goto out;
+               return false;
 
-       if (test_thread_flag(TIF_MEMDIE) || fatal_signal_pending(current))
-               goto out_memcg;
+       if (!handle)
+               goto cleanup;
 
        owait.memcg = memcg;
        owait.wait.flags = 0;
@@ -2271,13 +2222,25 @@ bool mem_cgroup_oom_synchronize(void)
        INIT_LIST_HEAD(&owait.wait.task_list);
 
        prepare_to_wait(&memcg_oom_waitq, &owait.wait, TASK_KILLABLE);
-       /* Only sleep if we didn't miss any wakeups since OOM */
-       if (atomic_read(&memcg->oom_wakeups) == current->memcg_oom.wakeups)
+       mem_cgroup_mark_under_oom(memcg);
+
+       locked = mem_cgroup_oom_trylock(memcg);
+
+       if (locked)
+               mem_cgroup_oom_notify(memcg);
+
+       if (locked && !memcg->oom_kill_disable) {
+               mem_cgroup_unmark_under_oom(memcg);
+               finish_wait(&memcg_oom_waitq, &owait.wait);
+               mem_cgroup_out_of_memory(memcg, current->memcg_oom.gfp_mask,
+                                        current->memcg_oom.order);
+       } else {
                schedule();
-       finish_wait(&memcg_oom_waitq, &owait.wait);
-out_memcg:
-       mem_cgroup_unmark_under_oom(memcg);
-       if (current->memcg_oom.oom_locked) {
+               mem_cgroup_unmark_under_oom(memcg);
+               finish_wait(&memcg_oom_waitq, &owait.wait);
+       }
+
+       if (locked) {
                mem_cgroup_oom_unlock(memcg);
                /*
                 * There is no guarantee that an OOM-lock contender
@@ -2286,10 +2249,9 @@ out_memcg:
                 */
                memcg_oom_recover(memcg);
        }
+cleanup:
+       current->memcg_oom.memcg = NULL;
        css_put(&memcg->css);
-       current->memcg_oom.wait_on_memcg = NULL;
-out:
-       current->memcg_oom.in_memcg_oom = 0;
        return true;
 }
 
@@ -2703,6 +2665,9 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
                     || fatal_signal_pending(current)))
                goto bypass;
 
+       if (unlikely(task_in_memcg_oom(current)))
+               goto bypass;
+
        /*
         * We always charge the cgroup the mm_struct belongs to.
         * The mm_struct's mem_cgroup changes on task migration if the
@@ -2801,6 +2766,8 @@ done:
        return 0;
 nomem:
        *ptr = NULL;
+       if (gfp_mask & __GFP_NOFAIL)
+               return 0;
        return -ENOMEM;
 bypass:
        *ptr = root_mem_cgroup;
index ca00039471152eae75bb8321a129a4edfc6f580e..1311f26497e6a0f776682ed8a7e23b8620a5b9ad 100644 (file)
@@ -837,6 +837,8 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
                                         */
                                        make_migration_entry_read(&entry);
                                        pte = swp_entry_to_pte(entry);
+                                       if (pte_swp_soft_dirty(*src_pte))
+                                               pte = pte_swp_mksoft_dirty(pte);
                                        set_pte_at(src_mm, addr, src_pte, pte);
                                }
                        }
@@ -3863,15 +3865,21 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
         * space.  Kernel faults are handled more gracefully.
         */
        if (flags & FAULT_FLAG_USER)
-               mem_cgroup_enable_oom();
+               mem_cgroup_oom_enable();
 
        ret = __handle_mm_fault(mm, vma, address, flags);
 
-       if (flags & FAULT_FLAG_USER)
-               mem_cgroup_disable_oom();
-
-       if (WARN_ON(task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM)))
-               mem_cgroup_oom_synchronize();
+       if (flags & FAULT_FLAG_USER) {
+               mem_cgroup_oom_disable();
+                /*
+                 * The task may have entered a memcg OOM situation but
+                 * if the allocation error was handled gracefully (no
+                 * VM_FAULT_OOM), there is no need to kill anything.
+                 * Just clean up the OOM state peacefully.
+                 */
+                if (task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM))
+                        mem_cgroup_oom_synchronize(false);
+       }
 
        return ret;
 }
index a26bccd44ccb0a907662c08135399462bd816b9c..7a7325ee1d089696a8073a84d2f748f326124805 100644 (file)
@@ -161,6 +161,8 @@ static int remove_migration_pte(struct page *new, struct vm_area_struct *vma,
 
        get_page(new);
        pte = pte_mkold(mk_pte(new, vma->vm_page_prot));
+       if (pte_swp_soft_dirty(*ptep))
+               pte = pte_mksoft_dirty(pte);
        if (is_write_migration_entry(entry))
                pte = pte_mkwrite(pte);
 #ifdef CONFIG_HUGETLB_PAGE
index 94722a4d6b438311de1d1690d81a0d598a907339..a3af058f68e4d9f434337d0dcd6127d5d8c6d039 100644 (file)
@@ -94,13 +94,16 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
                        swp_entry_t entry = pte_to_swp_entry(oldpte);
 
                        if (is_write_migration_entry(entry)) {
+                               pte_t newpte;
                                /*
                                 * A protection check is difficult so
                                 * just be safe and disable write
                                 */
                                make_migration_entry_read(&entry);
-                               set_pte_at(mm, addr, pte,
-                                       swp_entry_to_pte(entry));
+                               newpte = swp_entry_to_pte(entry);
+                               if (pte_swp_soft_dirty(oldpte))
+                                       newpte = pte_swp_mksoft_dirty(newpte);
+                               set_pte_at(mm, addr, pte, newpte);
                        }
                        pages++;
                }
index 91b13d6a16d453b50894e6028800b92399bf8f14..0843feb66f3d0236abd4386b5bfd0170c24ae0ef 100644 (file)
@@ -25,7 +25,6 @@
 #include <asm/uaccess.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
-#include <asm/pgalloc.h>
 
 #include "internal.h"
 
@@ -63,10 +62,8 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma,
                return NULL;
 
        pmd = pmd_alloc(mm, pud, addr);
-       if (!pmd) {
-               pud_free(mm, pud);
+       if (!pmd)
                return NULL;
-       }
 
        VM_BUG_ON(pmd_trans_huge(*pmd));
 
index 314e9d2743813ea5e52c08929b8a4cbb4621dfa9..6738c47f1f7280edc5f3fe610b2658195a0a77e0 100644 (file)
@@ -680,7 +680,7 @@ void pagefault_out_of_memory(void)
 {
        struct zonelist *zonelist;
 
-       if (mem_cgroup_oom_synchronize())
+       if (mem_cgroup_oom_synchronize(true))
                return;
 
        zonelist = node_zonelist(first_online_node, GFP_KERNEL);
index f5236f804aa6cdf9800f445c31950a52cdd6b88f..63807583d8e89f1c96f8b05bcf5fe422ed200c26 100644 (file)
@@ -1210,11 +1210,11 @@ static unsigned long dirty_poll_interval(unsigned long dirty,
        return 1;
 }
 
-static long bdi_max_pause(struct backing_dev_info *bdi,
-                         unsigned long bdi_dirty)
+static unsigned long bdi_max_pause(struct backing_dev_info *bdi,
+                                  unsigned long bdi_dirty)
 {
-       long bw = bdi->avg_write_bandwidth;
-       long t;
+       unsigned long bw = bdi->avg_write_bandwidth;
+       unsigned long t;
 
        /*
         * Limit pause time for small memory systems. If sleeping for too long
@@ -1226,7 +1226,7 @@ static long bdi_max_pause(struct backing_dev_info *bdi,
        t = bdi_dirty / (1 + bw / roundup_pow_of_two(1 + HZ / 8));
        t++;
 
-       return min_t(long, t, MAX_PAUSE);
+       return min_t(unsigned long, t, MAX_PAUSE);
 }
 
 static long bdi_min_pause(struct backing_dev_info *bdi,
index a3443278ce3a693b4c2625df3752a59e975abca3..e2e98af703ea9fdcbab4bcd034bc82a1482c9ca6 100644 (file)
@@ -56,6 +56,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
                        continue;
                }
 
+#if !defined(CONFIG_SLUB) || !defined(CONFIG_SLUB_DEBUG_ON)
                /*
                 * For simplicity, we won't check this in the list of memcg
                 * caches. We have control over memcg naming, and if there
@@ -69,6 +70,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
                        s = NULL;
                        return -EINVAL;
                }
+#endif
        }
 
        WARN_ON(strchr(name, ' '));     /* It confuses parsers */
index 3963fc24fcc1b6f8c4d365de4d99bda8993311b7..de7c904e52e507079f5bae7a2b7854a9d7cf80b0 100644 (file)
@@ -1824,6 +1824,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
        struct filename *pathname;
        int i, type, prev;
        int err;
+       unsigned int old_block_size;
 
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
@@ -1914,6 +1915,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
        }
 
        swap_file = p->swap_file;
+       old_block_size = p->old_block_size;
        p->swap_file = NULL;
        p->max = 0;
        swap_map = p->swap_map;
@@ -1938,7 +1940,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
        inode = mapping->host;
        if (S_ISBLK(inode->i_mode)) {
                struct block_device *bdev = I_BDEV(inode);
-               set_blocksize(bdev, p->old_block_size);
+               set_blocksize(bdev, old_block_size);
                blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
        } else {
                mutex_lock(&inode->i_mutex);
index 53f2f82f83ae0d16bf19646cdb5b3bce5fc4e4cf..eea668d9cff6c578ada0cf6c02eca5e22de5598d 100644 (file)
@@ -211,6 +211,7 @@ void unregister_shrinker(struct shrinker *shrinker)
        down_write(&shrinker_rwsem);
        list_del(&shrinker->list);
        up_write(&shrinker_rwsem);
+       kfree(shrinker->nr_deferred);
 }
 EXPORT_SYMBOL(unregister_shrinker);
 
index 841e35f1db22caff3afd03c104403f0c744776cb..d93510c6aa2da860d779570cbf0a4c7cee278ad5 100644 (file)
@@ -804,6 +804,10 @@ static void zswap_frontswap_invalidate_area(unsigned type)
        }
        tree->rbroot = RB_ROOT;
        spin_unlock(&tree->lock);
+
+       zbud_destroy_pool(tree->pool);
+       kfree(tree);
+       zswap_trees[type] = NULL;
 }
 
 static struct zbud_ops zswap_zbud_ops = {
index 95c2b2689a03aa521bc923323f521a8c191d107d..7db9954f1af2c56c42400746f367f5f4d9906ca8 100644 (file)
@@ -580,15 +580,13 @@ static struct aa_namespace *__next_namespace(struct aa_namespace *root,
 
        /* check if the next ns is a sibling, parent, gp, .. */
        parent = ns->parent;
-       while (parent) {
+       while (ns != root) {
                mutex_unlock(&ns->lock);
                next = list_entry_next(ns, base.list);
                if (!list_entry_is_head(next, &parent->sub_ns, base.list)) {
                        mutex_lock(&next->lock);
                        return next;
                }
-               if (parent == root)
-                       return NULL;
                ns = parent;
                parent = parent->parent;
        }
index 345bec07a27d9292dbfc1306d1f5e12563eaa891..705c2879d3a94a79e10d1190468483c2f9d7192a 100644 (file)
@@ -610,6 +610,7 @@ void aa_free_profile(struct aa_profile *profile)
        aa_put_dfa(profile->policy.dfa);
        aa_put_replacedby(profile->replacedby);
 
+       kzfree(profile->hash);
        kzfree(profile);
 }
 
index e6f4633b8dd5b6b9cdfebc6409fc6db279393aed..99a466822a7d9eb3d73dd56da74911c3cb3d0173 100644 (file)
@@ -117,8 +117,7 @@ static inline void pxa_ac97_warm_pxa25x(void)
 {
        gsr_bits = 0;
 
-       GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN;
-       wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
+       GCR |= GCR_WARM_RST;
 }
 
 static inline void pxa_ac97_cold_pxa25x(void)
@@ -129,8 +128,6 @@ static inline void pxa_ac97_cold_pxa25x(void)
        gsr_bits = 0;
 
        GCR = GCR_COLD_RST;
-       GCR |= GCR_CDONE_IE|GCR_SDONE_IE;
-       wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
 }
 #endif
 
@@ -149,8 +146,6 @@ static inline void pxa_ac97_warm_pxa27x(void)
 
 static inline void pxa_ac97_cold_pxa27x(void)
 {
-       unsigned int timeout;
-
        GCR &=  GCR_COLD_RST;  /* clear everything but nCRST */
        GCR &= ~GCR_COLD_RST;  /* then assert nCRST */
 
@@ -161,29 +156,20 @@ static inline void pxa_ac97_cold_pxa27x(void)
        udelay(5);
        clk_disable(ac97conf_clk);
        GCR = GCR_COLD_RST | GCR_WARM_RST;
-       timeout = 100;     /* wait for the codec-ready bit to be set */
-       while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
-               mdelay(1);
 }
 #endif
 
 #ifdef CONFIG_PXA3xx
 static inline void pxa_ac97_warm_pxa3xx(void)
 {
-       int timeout = 100;
-
        gsr_bits = 0;
 
        /* Can't use interrupts */
        GCR |= GCR_WARM_RST;
-       while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
-               mdelay(1);
 }
 
 static inline void pxa_ac97_cold_pxa3xx(void)
 {
-       int timeout = 1000;
-
        /* Hold CLKBPB for 100us */
        GCR = 0;
        GCR = GCR_CLKBPB;
@@ -199,14 +185,13 @@ static inline void pxa_ac97_cold_pxa3xx(void)
        GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
 
        GCR = GCR_WARM_RST | GCR_COLD_RST;
-       while (!(GSR & (GSR_PCR | GSR_SCR)) && timeout--)
-               mdelay(10);
 }
 #endif
 
 bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
 {
        unsigned long gsr;
+       unsigned int timeout = 100;
 
 #ifdef CONFIG_PXA25x
        if (cpu_is_pxa25x())
@@ -224,6 +209,10 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
        else
 #endif
                BUG();
+
+       while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
+               mdelay(1);
+
        gsr = GSR | gsr_bits;
        if (!(gsr & (GSR_PCR | GSR_SCR))) {
                printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
@@ -239,6 +228,7 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset);
 bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
 {
        unsigned long gsr;
+       unsigned int timeout = 1000;
 
 #ifdef CONFIG_PXA25x
        if (cpu_is_pxa25x())
@@ -257,6 +247,9 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
 #endif
                BUG();
 
+       while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
+               mdelay(1);
+
        gsr = GSR | gsr_bits;
        if (!(gsr & (GSR_PCR | GSR_SCR))) {
                printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
index bea523a5d852e11f9d06e1d682e065b699f347c8..3eb47d0006a74172d7a925cf31ca5d0f9f795df0 100644 (file)
@@ -123,6 +123,7 @@ static int snd_compr_open(struct inode *inode, struct file *f)
        }
        runtime->state = SNDRV_PCM_STATE_OPEN;
        init_waitqueue_head(&runtime->sleep);
+       init_waitqueue_head(&runtime->wait);
        data->stream.runtime = runtime;
        f->private_data = (void *)data;
        mutex_lock(&compr->lock);
@@ -682,12 +683,34 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
        if (!retval) {
                stream->runtime->state = SNDRV_PCM_STATE_SETUP;
                wake_up(&stream->runtime->sleep);
+               snd_compr_drain_notify(stream);
                stream->runtime->total_bytes_available = 0;
                stream->runtime->total_bytes_transferred = 0;
        }
        return retval;
 }
 
+static int snd_compress_wait_for_drain(struct snd_compr_stream *stream)
+{
+       /*
+        * We are called with lock held. So drop the lock while we wait for
+        * drain complete notfication from the driver
+        *
+        * It is expected that driver will notify the drain completion and then
+        * stream will be moved to SETUP state, even if draining resulted in an
+        * error. We can trigger next track after this.
+        */
+       stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
+       mutex_unlock(&stream->device->lock);
+
+       wait_event(stream->runtime->wait, stream->runtime->drain_wake);
+
+       wake_up(&stream->runtime->sleep);
+       mutex_lock(&stream->device->lock);
+
+       return 0;
+}
+
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
        int retval;
@@ -695,11 +718,17 @@ static int snd_compr_drain(struct snd_compr_stream *stream)
        if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
                        stream->runtime->state == SNDRV_PCM_STATE_SETUP)
                return -EPERM;
+
+       stream->runtime->drain_wake = 0;
        retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);
-       if (!retval) {
-               stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
+       if (retval) {
+               pr_err("SND_COMPR_TRIGGER_DRAIN failed %d\n", retval);
                wake_up(&stream->runtime->sleep);
+               return retval;
        }
+
+       retval = snd_compress_wait_for_drain(stream);
+       stream->runtime->state = SNDRV_PCM_STATE_SETUP;
        return retval;
 }
 
@@ -735,10 +764,16 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
        if (stream->next_track == false)
                return -EPERM;
 
+       stream->runtime->drain_wake = 0;
        retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN);
+       if (retval) {
+               pr_err("Partial drain returned failure\n");
+               wake_up(&stream->runtime->sleep);
+               return retval;
+       }
 
        stream->next_track = false;
-       return retval;
+       return snd_compress_wait_for_drain(stream);
 }
 
 static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
index bdf826f4fe0ceda5e74bc7e9ad3dfe0a78e59b63..51a79218815bdf00b0858f999e5c6e572c6f76ee 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/seq_file.h>
 #include <asm/uaccess.h>
 #include <linux/dma-mapping.h>
+#include <linux/genalloc.h>
 #include <linux/moduleparam.h>
 #include <linux/mutex.h>
 #include <sound/memalloc.h>
@@ -157,6 +158,46 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr,
        dec_snd_pages(pg);
        dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma);
 }
+
+/**
+ * snd_malloc_dev_iram - allocate memory from on-chip internal ram
+ * @dmab: buffer allocation record to store the allocated data
+ * @size: number of bytes to allocate from the iram
+ *
+ * This function requires iram phandle provided via of_node
+ */
+void snd_malloc_dev_iram(struct snd_dma_buffer *dmab, size_t size)
+{
+       struct device *dev = dmab->dev.dev;
+       struct gen_pool *pool = NULL;
+
+       if (dev->of_node)
+               pool = of_get_named_gen_pool(dev->of_node, "iram", 0);
+
+       if (!pool)
+               return;
+
+       /* Assign the pool into private_data field */
+       dmab->private_data = pool;
+
+       dmab->area = (void *)gen_pool_alloc(pool, size);
+       if (!dmab->area)
+               return;
+
+       dmab->addr = gen_pool_virt_to_phys(pool, (unsigned long)dmab->area);
+}
+
+/**
+ * snd_free_dev_iram - free allocated specific memory from on-chip internal ram
+ * @dmab: buffer allocation record to store the allocated data
+ */
+void snd_free_dev_iram(struct snd_dma_buffer *dmab)
+{
+       struct gen_pool *pool = dmab->private_data;
+
+       if (pool && dmab->area)
+               gen_pool_free(pool, (unsigned long)dmab->area, dmab->bytes);
+}
 #endif /* CONFIG_HAS_DMA */
 
 /*
@@ -197,6 +238,16 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
                dmab->addr = 0;
                break;
 #ifdef CONFIG_HAS_DMA
+#ifdef CONFIG_GENERIC_ALLOCATOR
+       case SNDRV_DMA_TYPE_DEV_IRAM:
+               snd_malloc_dev_iram(dmab, size);
+               if (dmab->area)
+                       break;
+               /* Internal memory might have limited size and no enough space,
+                * so if we fail to malloc, try to fetch memory traditionally.
+                */
+               dmab->dev.type = SNDRV_DMA_TYPE_DEV;
+#endif /* CONFIG_GENERIC_ALLOCATOR */
        case SNDRV_DMA_TYPE_DEV:
                dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr);
                break;
@@ -269,6 +320,11 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
                snd_free_pages(dmab->area, dmab->bytes);
                break;
 #ifdef CONFIG_HAS_DMA
+#ifdef CONFIG_GENERIC_ALLOCATOR
+       case SNDRV_DMA_TYPE_DEV_IRAM:
+               snd_free_dev_iram(dmab);
+               break;
+#endif /* CONFIG_GENERIC_ALLOCATOR */
        case SNDRV_DMA_TYPE_DEV:
                snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
                break;
index a68d4c6d702c80cd461def1c84c4a91a254b21a4..b71be579c6ecb3a5775d4a48e93adad8f530d2dc 100644 (file)
@@ -3199,6 +3199,14 @@ int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream,
                             struct vm_area_struct *area)
 {
        area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
+#ifdef CONFIG_GENERIC_ALLOCATOR
+       if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_IRAM) {
+               area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
+               return remap_pfn_range(area, area->vm_start,
+                               substream->dma_buffer.addr >> PAGE_SHIFT,
+                               area->vm_end - area->vm_start, area->vm_page_prot);
+       }
+#endif /* CONFIG_GENERIC_ALLOCATOR */
 #ifdef ARCH_HAS_DMA_MMAP_COHERENT
        if (!substream->ops->page &&
            substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV)
index ea063e1f87221e982558ec892024e5bdb7793b89..b3e274fe4a77438a463766c9d364045dbe8cbaf7 100644 (file)
@@ -11,6 +11,21 @@ config SND_FIREWIRE_LIB
        tristate
        depends on SND_PCM
 
+config SND_DICE
+       tristate "DICE-based DACs (EXPERIMENTAL)"
+       select SND_HWDEP
+       select SND_PCM
+       select SND_FIREWIRE_LIB
+       help
+         Say Y here to include support for many DACs based on the DICE
+         chip family (DICE-II/Jr/Mini) from TC Applied Technologies.
+
+         At the moment, this driver supports playback only.  If you
+         want to use devices that support capturing, use FFADO instead.
+
+         To compile this driver as a module, choose M here: the module
+         will be called snd-dice.
+
 config SND_FIREWIRE_SPEAKERS
        tristate "FireWire speakers"
        select SND_PCM
index 460179df5bb526ee06f90fa7ffd03ef638024e3b..509955061d30f62d44216fb9913282091d0bca93 100644 (file)
@@ -1,10 +1,12 @@
 snd-firewire-lib-objs := lib.o iso-resources.o packets-buffer.o \
                         fcp.o cmp.o amdtp.o
+snd-dice-objs := dice.o
 snd-firewire-speakers-objs := speakers.o
 snd-isight-objs := isight.o
 snd-scs1x-objs := scs1x.o
 
 obj-$(CONFIG_SND_FIREWIRE_LIB) += snd-firewire-lib.o
+obj-$(CONFIG_SND_DICE) += snd-dice.o
 obj-$(CONFIG_SND_FIREWIRE_SPEAKERS) += snd-firewire-speakers.o
 obj-$(CONFIG_SND_ISIGHT) += snd-isight.o
 obj-$(CONFIG_SND_SCS1X) += snd-scs1x.o
index ea995af6d049ec63b86f8fb59cf374640db9cc56..d3226892ad6b44953fd4d980d65874ac40535768 100644 (file)
@@ -42,9 +42,6 @@ static void pcm_period_tasklet(unsigned long data);
 int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit,
                          enum cip_out_flags flags)
 {
-       if (flags != CIP_NONBLOCKING)
-               return -EINVAL;
-
        s->unit = fw_unit_get(unit);
        s->flags = flags;
        s->context = ERR_PTR(-1);
@@ -62,73 +59,91 @@ EXPORT_SYMBOL(amdtp_out_stream_init);
  */
 void amdtp_out_stream_destroy(struct amdtp_out_stream *s)
 {
-       WARN_ON(!IS_ERR(s->context));
+       WARN_ON(amdtp_out_stream_running(s));
        mutex_destroy(&s->mutex);
        fw_unit_put(s->unit);
 }
 EXPORT_SYMBOL(amdtp_out_stream_destroy);
 
+const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT] = {
+       [CIP_SFC_32000]  =  8,
+       [CIP_SFC_44100]  =  8,
+       [CIP_SFC_48000]  =  8,
+       [CIP_SFC_88200]  = 16,
+       [CIP_SFC_96000]  = 16,
+       [CIP_SFC_176400] = 32,
+       [CIP_SFC_192000] = 32,
+};
+EXPORT_SYMBOL(amdtp_syt_intervals);
+
 /**
- * amdtp_out_stream_set_rate - set the sample rate
+ * amdtp_out_stream_set_parameters - set stream parameters
  * @s: the AMDTP output stream to configure
  * @rate: the sample rate
+ * @pcm_channels: the number of PCM samples in each data block, to be encoded
+ *                as AM824 multi-bit linear audio
+ * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels)
  *
- * The sample rate must be set before the stream is started, and must not be
+ * The parameters must be set before the stream is started, and must not be
  * changed while the stream is running.
  */
-void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate)
+void amdtp_out_stream_set_parameters(struct amdtp_out_stream *s,
+                                    unsigned int rate,
+                                    unsigned int pcm_channels,
+                                    unsigned int midi_ports)
 {
-       static const struct {
-               unsigned int rate;
-               unsigned int syt_interval;
-       } rate_info[] = {
-               [CIP_SFC_32000]  = {  32000,  8, },
-               [CIP_SFC_44100]  = {  44100,  8, },
-               [CIP_SFC_48000]  = {  48000,  8, },
-               [CIP_SFC_88200]  = {  88200, 16, },
-               [CIP_SFC_96000]  = {  96000, 16, },
-               [CIP_SFC_176400] = { 176400, 32, },
-               [CIP_SFC_192000] = { 192000, 32, },
+       static const unsigned int rates[] = {
+               [CIP_SFC_32000]  =  32000,
+               [CIP_SFC_44100]  =  44100,
+               [CIP_SFC_48000]  =  48000,
+               [CIP_SFC_88200]  =  88200,
+               [CIP_SFC_96000]  =  96000,
+               [CIP_SFC_176400] = 176400,
+               [CIP_SFC_192000] = 192000,
        };
        unsigned int sfc;
 
-       if (WARN_ON(!IS_ERR(s->context)))
+       if (WARN_ON(amdtp_out_stream_running(s)))
                return;
 
-       for (sfc = 0; sfc < ARRAY_SIZE(rate_info); ++sfc)
-               if (rate_info[sfc].rate == rate) {
-                       s->sfc = sfc;
-                       s->syt_interval = rate_info[sfc].syt_interval;
-                       return;
-               }
+       for (sfc = 0; sfc < CIP_SFC_COUNT; ++sfc)
+               if (rates[sfc] == rate)
+                       goto sfc_found;
        WARN_ON(1);
+       return;
+
+sfc_found:
+       s->dual_wire = (s->flags & CIP_HI_DUALWIRE) && sfc > CIP_SFC_96000;
+       if (s->dual_wire) {
+               sfc -= 2;
+               rate /= 2;
+               pcm_channels *= 2;
+       }
+       s->sfc = sfc;
+       s->data_block_quadlets = pcm_channels + DIV_ROUND_UP(midi_ports, 8);
+       s->pcm_channels = pcm_channels;
+       s->midi_ports = midi_ports;
+
+       s->syt_interval = amdtp_syt_intervals[sfc];
+
+       /* default buffering in the device */
+       s->transfer_delay = TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE;
+       if (s->flags & CIP_BLOCKING)
+               /* additional buffering needed to adjust for no-data packets */
+               s->transfer_delay += TICKS_PER_SECOND * s->syt_interval / rate;
 }
-EXPORT_SYMBOL(amdtp_out_stream_set_rate);
+EXPORT_SYMBOL(amdtp_out_stream_set_parameters);
 
 /**
  * amdtp_out_stream_get_max_payload - get the stream's packet size
  * @s: the AMDTP output stream
  *
  * This function must not be called before the stream has been configured
- * with amdtp_out_stream_set_hw_params(), amdtp_out_stream_set_pcm(), and
- * amdtp_out_stream_set_midi().
+ * with amdtp_out_stream_set_parameters().
  */
 unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s)
 {
-       static const unsigned int max_data_blocks[] = {
-               [CIP_SFC_32000]  =  4,
-               [CIP_SFC_44100]  =  6,
-               [CIP_SFC_48000]  =  6,
-               [CIP_SFC_88200]  = 12,
-               [CIP_SFC_96000]  = 12,
-               [CIP_SFC_176400] = 23,
-               [CIP_SFC_192000] = 24,
-       };
-
-       s->data_block_quadlets = s->pcm_channels;
-       s->data_block_quadlets += DIV_ROUND_UP(s->midi_ports, 8);
-
-       return 8 + max_data_blocks[s->sfc] * 4 * s->data_block_quadlets;
+       return 8 + s->syt_interval * s->data_block_quadlets * 4;
 }
 EXPORT_SYMBOL(amdtp_out_stream_get_max_payload);
 
@@ -138,19 +153,26 @@ static void amdtp_write_s16(struct amdtp_out_stream *s,
 static void amdtp_write_s32(struct amdtp_out_stream *s,
                            struct snd_pcm_substream *pcm,
                            __be32 *buffer, unsigned int frames);
+static void amdtp_write_s16_dualwire(struct amdtp_out_stream *s,
+                                    struct snd_pcm_substream *pcm,
+                                    __be32 *buffer, unsigned int frames);
+static void amdtp_write_s32_dualwire(struct amdtp_out_stream *s,
+                                    struct snd_pcm_substream *pcm,
+                                    __be32 *buffer, unsigned int frames);
 
 /**
  * amdtp_out_stream_set_pcm_format - set the PCM format
  * @s: the AMDTP output stream to configure
  * @format: the format of the ALSA PCM device
  *
- * The sample format must be set before the stream is started, and must not be
- * changed while the stream is running.
+ * The sample format must be set after the other paramters (rate/PCM channels/
+ * MIDI) and before the stream is started, and must not be changed while the
+ * stream is running.
  */
 void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s,
                                     snd_pcm_format_t format)
 {
-       if (WARN_ON(!IS_ERR(s->context)))
+       if (WARN_ON(amdtp_out_stream_running(s)))
                return;
 
        switch (format) {
@@ -158,10 +180,16 @@ void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s,
                WARN_ON(1);
                /* fall through */
        case SNDRV_PCM_FORMAT_S16:
-               s->transfer_samples = amdtp_write_s16;
+               if (s->dual_wire)
+                       s->transfer_samples = amdtp_write_s16_dualwire;
+               else
+                       s->transfer_samples = amdtp_write_s16;
                break;
        case SNDRV_PCM_FORMAT_S32:
-               s->transfer_samples = amdtp_write_s32;
+               if (s->dual_wire)
+                       s->transfer_samples = amdtp_write_s32_dualwire;
+               else
+                       s->transfer_samples = amdtp_write_s32;
                break;
        }
 }
@@ -248,7 +276,7 @@ static unsigned int calculate_syt(struct amdtp_out_stream *s,
        s->last_syt_offset = syt_offset;
 
        if (syt_offset < TICKS_PER_CYCLE) {
-               syt_offset += TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE;
+               syt_offset += s->transfer_delay;
                syt = (cycle + syt_offset / TICKS_PER_CYCLE) << 12;
                syt += syt_offset % TICKS_PER_CYCLE;
 
@@ -268,7 +296,7 @@ static void amdtp_write_s32(struct amdtp_out_stream *s,
 
        channels = s->pcm_channels;
        src = (void *)runtime->dma_area +
-                       s->pcm_buffer_pointer * (runtime->frame_bits / 8);
+                       frames_to_bytes(runtime, s->pcm_buffer_pointer);
        remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer;
        frame_step = s->data_block_quadlets - channels;
 
@@ -294,7 +322,7 @@ static void amdtp_write_s16(struct amdtp_out_stream *s,
 
        channels = s->pcm_channels;
        src = (void *)runtime->dma_area +
-                       s->pcm_buffer_pointer * (runtime->frame_bits / 8);
+                       frames_to_bytes(runtime, s->pcm_buffer_pointer);
        remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer;
        frame_step = s->data_block_quadlets - channels;
 
@@ -310,6 +338,68 @@ static void amdtp_write_s16(struct amdtp_out_stream *s,
        }
 }
 
+static void amdtp_write_s32_dualwire(struct amdtp_out_stream *s,
+                                    struct snd_pcm_substream *pcm,
+                                    __be32 *buffer, unsigned int frames)
+{
+       struct snd_pcm_runtime *runtime = pcm->runtime;
+       unsigned int channels, frame_adjust_1, frame_adjust_2, i, c;
+       const u32 *src;
+
+       channels = s->pcm_channels;
+       src = (void *)runtime->dma_area +
+                       s->pcm_buffer_pointer * (runtime->frame_bits / 8);
+       frame_adjust_1 = channels - 1;
+       frame_adjust_2 = 1 - (s->data_block_quadlets - channels);
+
+       channels /= 2;
+       for (i = 0; i < frames; ++i) {
+               for (c = 0; c < channels; ++c) {
+                       *buffer = cpu_to_be32((*src >> 8) | 0x40000000);
+                       src++;
+                       buffer += 2;
+               }
+               buffer -= frame_adjust_1;
+               for (c = 0; c < channels; ++c) {
+                       *buffer = cpu_to_be32((*src >> 8) | 0x40000000);
+                       src++;
+                       buffer += 2;
+               }
+               buffer -= frame_adjust_2;
+       }
+}
+
+static void amdtp_write_s16_dualwire(struct amdtp_out_stream *s,
+                                    struct snd_pcm_substream *pcm,
+                                    __be32 *buffer, unsigned int frames)
+{
+       struct snd_pcm_runtime *runtime = pcm->runtime;
+       unsigned int channels, frame_adjust_1, frame_adjust_2, i, c;
+       const u16 *src;
+
+       channels = s->pcm_channels;
+       src = (void *)runtime->dma_area +
+                       s->pcm_buffer_pointer * (runtime->frame_bits / 8);
+       frame_adjust_1 = channels - 1;
+       frame_adjust_2 = 1 - (s->data_block_quadlets - channels);
+
+       channels /= 2;
+       for (i = 0; i < frames; ++i) {
+               for (c = 0; c < channels; ++c) {
+                       *buffer = cpu_to_be32((*src << 8) | 0x40000000);
+                       src++;
+                       buffer += 2;
+               }
+               buffer -= frame_adjust_1;
+               for (c = 0; c < channels; ++c) {
+                       *buffer = cpu_to_be32((*src << 8) | 0x40000000);
+                       src++;
+                       buffer += 2;
+               }
+               buffer -= frame_adjust_2;
+       }
+}
+
 static void amdtp_fill_pcm_silence(struct amdtp_out_stream *s,
                                   __be32 *buffer, unsigned int frames)
 {
@@ -344,8 +434,17 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
                return;
        index = s->packet_index;
 
-       data_blocks = calculate_data_blocks(s);
        syt = calculate_syt(s, cycle);
+       if (!(s->flags & CIP_BLOCKING)) {
+               data_blocks = calculate_data_blocks(s);
+       } else {
+               if (syt != 0xffff) {
+                       data_blocks = s->syt_interval;
+               } else {
+                       data_blocks = 0;
+                       syt = 0xffffff;
+               }
+       }
 
        buffer = s->buffer.packets[index].buffer;
        buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) |
@@ -386,6 +485,9 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
        s->packet_index = index;
 
        if (pcm) {
+               if (s->dual_wire)
+                       data_blocks *= 2;
+
                ptr = s->pcm_buffer_pointer + data_blocks;
                if (ptr >= pcm->runtime->buffer_size)
                        ptr -= pcm->runtime->buffer_size;
@@ -455,9 +557,8 @@ static int queue_initial_skip_packets(struct amdtp_out_stream *s)
  * @speed: firewire speed code
  *
  * The stream cannot be started until it has been configured with
- * amdtp_out_stream_set_hw_params(), amdtp_out_stream_set_pcm(), and
- * amdtp_out_stream_set_midi(); and it must be started before any
- * PCM or MIDI device can be started.
+ * amdtp_out_stream_set_parameters() and amdtp_out_stream_set_pcm_format(),
+ * and it must be started before any PCM or MIDI device can be started.
  */
 int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed)
 {
@@ -477,7 +578,7 @@ int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed)
 
        mutex_lock(&s->mutex);
 
-       if (WARN_ON(!IS_ERR(s->context) ||
+       if (WARN_ON(amdtp_out_stream_running(s) ||
                    (!s->pcm_channels && !s->midi_ports))) {
                err = -EBADFD;
                goto err_unlock;
@@ -573,7 +674,7 @@ void amdtp_out_stream_stop(struct amdtp_out_stream *s)
 {
        mutex_lock(&s->mutex);
 
-       if (IS_ERR(s->context)) {
+       if (!amdtp_out_stream_running(s)) {
                mutex_unlock(&s->mutex);
                return;
        }
index f6103d68c4b1660bf9d61ba8d0c053086eec923b..839ebf812d79e47302e3c4c57b5f2f74695551b7 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef SOUND_FIREWIRE_AMDTP_H_INCLUDED
 #define SOUND_FIREWIRE_AMDTP_H_INCLUDED
 
+#include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
 #include "packets-buffer.h"
  *     sample_rate/8000 samples, with rounding up or down to adjust
  *     for clock skew and left-over fractional samples.  This should
  *     be used if supported by the device.
+ * @CIP_BLOCKING: In blocking mode, each packet contains either zero or
+ *     SYT_INTERVAL samples, with these two types alternating so that
+ *     the overall sample rate comes out right.
+ * @CIP_HI_DUALWIRE: At rates above 96 kHz, pretend that the stream runs
+ *     at half the actual sample rate with twice the number of channels;
+ *     two samples of a channel are stored consecutively in the packet.
+ *     Requires blocking mode and SYT_INTERVAL-aligned PCM buffer size.
  */
 enum cip_out_flags {
-       CIP_NONBLOCKING = 0,
+       CIP_NONBLOCKING = 0x00,
+       CIP_BLOCKING    = 0x01,
+       CIP_HI_DUALWIRE = 0x02,
 };
 
 /**
@@ -27,6 +37,7 @@ enum cip_sfc {
        CIP_SFC_96000  = 4,
        CIP_SFC_176400 = 5,
        CIP_SFC_192000 = 6,
+       CIP_SFC_COUNT
 };
 
 #define AMDTP_OUT_PCM_FORMAT_BITS      (SNDRV_PCM_FMTBIT_S16 | \
@@ -43,6 +54,7 @@ struct amdtp_out_stream {
        struct mutex mutex;
 
        enum cip_sfc sfc;
+       bool dual_wire;
        unsigned int data_block_quadlets;
        unsigned int pcm_channels;
        unsigned int midi_ports;
@@ -51,6 +63,7 @@ struct amdtp_out_stream {
                                 __be32 *buffer, unsigned int frames);
 
        unsigned int syt_interval;
+       unsigned int transfer_delay;
        unsigned int source_node_id_field;
        struct iso_packets_buffer buffer;
 
@@ -74,7 +87,10 @@ int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit,
                          enum cip_out_flags flags);
 void amdtp_out_stream_destroy(struct amdtp_out_stream *s);
 
-void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate);
+void amdtp_out_stream_set_parameters(struct amdtp_out_stream *s,
+                                    unsigned int rate,
+                                    unsigned int pcm_channels,
+                                    unsigned int midi_ports);
 unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s);
 
 int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed);
@@ -87,31 +103,11 @@ void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s);
 unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s);
 void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s);
 
-/**
- * amdtp_out_stream_set_pcm - configure format of PCM samples
- * @s: the AMDTP output stream to be configured
- * @pcm_channels: the number of PCM samples in each data block, to be encoded
- *                as AM824 multi-bit linear audio
- *
- * This function must not be called while the stream is running.
- */
-static inline void amdtp_out_stream_set_pcm(struct amdtp_out_stream *s,
-                                           unsigned int pcm_channels)
-{
-       s->pcm_channels = pcm_channels;
-}
+extern const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT];
 
-/**
- * amdtp_out_stream_set_midi - configure format of MIDI data
- * @s: the AMDTP output stream to be configured
- * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels)
- *
- * This function must not be called while the stream is running.
- */
-static inline void amdtp_out_stream_set_midi(struct amdtp_out_stream *s,
-                                            unsigned int midi_ports)
+static inline bool amdtp_out_stream_running(struct amdtp_out_stream *s)
 {
-       s->midi_ports = midi_ports;
+       return !IS_ERR(s->context);
 }
 
 /**
index 645cb0ba429310f1a0c2569e1a7845a9bf0c4387..efdbf585e4046f7588f1e838139104beecc90c75 100644 (file)
@@ -48,9 +48,6 @@ static int pcr_modify(struct cmp_connection *c,
                      int (*check)(struct cmp_connection *c, __be32 pcr),
                      enum bus_reset_handling bus_reset_handling)
 {
-       struct fw_device *device = fw_parent_device(c->resources.unit);
-       int generation = c->resources.generation;
-       int rcode, errors = 0;
        __be32 old_arg, buffer[2];
        int err;
 
@@ -59,36 +56,31 @@ static int pcr_modify(struct cmp_connection *c,
                old_arg = buffer[0];
                buffer[1] = modify(c, buffer[0]);
 
-               rcode = fw_run_transaction(
-                               device->card, TCODE_LOCK_COMPARE_SWAP,
-                               device->node_id, generation, device->max_speed,
+               err = snd_fw_transaction(
+                               c->resources.unit, TCODE_LOCK_COMPARE_SWAP,
                                CSR_REGISTER_BASE + CSR_IPCR(c->pcr_index),
-                               buffer, 8);
-
-               if (rcode == RCODE_COMPLETE) {
-                       if (buffer[0] == old_arg) /* success? */
-                               break;
-
-                       if (check) {
-                               err = check(c, buffer[0]);
-                               if (err < 0)
-                                       return err;
-                       }
-               } else if (rcode == RCODE_GENERATION)
-                       goto bus_reset;
-               else if (rcode_is_permanent_error(rcode) || ++errors >= 3)
-                       goto io_error;
+                               buffer, 8,
+                               FW_FIXED_GENERATION | c->resources.generation);
+
+               if (err < 0) {
+                       if (err == -EAGAIN &&
+                           bus_reset_handling == SUCCEED_ON_BUS_RESET)
+                               err = 0;
+                       return err;
+               }
+
+               if (buffer[0] == old_arg) /* success? */
+                       break;
+
+               if (check) {
+                       err = check(c, buffer[0]);
+                       if (err < 0)
+                               return err;
+               }
        }
        c->last_pcr_value = buffer[1];
 
        return 0;
-
-io_error:
-       cmp_error(c, "transaction failed: %s\n", fw_rcode_string(rcode));
-       return -EIO;
-
-bus_reset:
-       return bus_reset_handling == ABORT_ON_BUS_RESET ? -EAGAIN : 0;
 }
 
 
@@ -108,7 +100,7 @@ int cmp_connection_init(struct cmp_connection *c,
 
        err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
                                 CSR_REGISTER_BASE + CSR_IMPR,
-                                &impr_be, 4);
+                                &impr_be, 4, 0);
        if (err < 0)
                return err;
        impr = be32_to_cpu(impr_be);
diff --git a/sound/firewire/dice-interface.h b/sound/firewire/dice-interface.h
new file mode 100644 (file)
index 0000000..27b044f
--- /dev/null
@@ -0,0 +1,371 @@
+#ifndef SOUND_FIREWIRE_DICE_INTERFACE_H_INCLUDED
+#define SOUND_FIREWIRE_DICE_INTERFACE_H_INCLUDED
+
+/*
+ * DICE device interface definitions
+ */
+
+/*
+ * Generally, all registers can be read like memory, i.e., with quadlet read or
+ * block read transactions with at least quadlet-aligned offset and length.
+ * Writes are not allowed except where noted; quadlet-sized registers must be
+ * written with a quadlet write transaction.
+ *
+ * All values are in big endian.  The DICE firmware runs on a little-endian CPU
+ * and just byte-swaps _all_ quadlets on the bus, so values without endianness
+ * (e.g. strings) get scrambled and must be byte-swapped again by the driver.
+ */
+
+/*
+ * Streaming is handled by the "DICE driver" interface.  Its registers are
+ * located in this private address space.
+ */
+#define DICE_PRIVATE_SPACE             0xffffe0000000uLL
+
+/*
+ * The registers are organized in several sections, which are organized
+ * separately to allow them to be extended individually.  Whether a register is
+ * supported can be detected by checking its offset against its section's size.
+ *
+ * The section offset values are relative to DICE_PRIVATE_SPACE; the offset/
+ * size values are measured in quadlets.  Read-only.
+ */
+#define DICE_GLOBAL_OFFSET             0x00
+#define DICE_GLOBAL_SIZE               0x04
+#define DICE_TX_OFFSET                 0x08
+#define DICE_TX_SIZE                   0x0c
+#define DICE_RX_OFFSET                 0x10
+#define DICE_RX_SIZE                   0x14
+#define DICE_EXT_SYNC_OFFSET           0x18
+#define DICE_EXT_SYNC_SIZE             0x1c
+#define DICE_UNUSED2_OFFSET            0x20
+#define DICE_UNUSED2_SIZE              0x24
+
+/*
+ * Global settings.
+ */
+
+/*
+ * Stores the full 64-bit address (node ID and offset in the node's address
+ * space) where the device will send notifications.  Must be changed with
+ * a compare/swap transaction by the owner.  This register is automatically
+ * cleared on a bus reset.
+ */
+#define GLOBAL_OWNER                   0x000
+#define  OWNER_NO_OWNER                        0xffff000000000000uLL
+#define  OWNER_NODE_SHIFT              48
+
+/*
+ * A bitmask with asynchronous events; read-only.  When any event(s) happen,
+ * the bits of previous events are cleared, and the value of this register is
+ * also written to the address stored in the owner register.
+ */
+#define GLOBAL_NOTIFICATION            0x008
+/* Some registers in the Rx/Tx sections may have changed. */
+#define  NOTIFY_RX_CFG_CHG             0x00000001
+#define  NOTIFY_TX_CFG_CHG             0x00000002
+/* Lock status of the current clock source may have changed. */
+#define  NOTIFY_LOCK_CHG               0x00000010
+/* Write to the clock select register has been finished. */
+#define  NOTIFY_CLOCK_ACCEPTED         0x00000020
+/* Lock status of some clock source has changed. */
+#define  NOTIFY_EXT_STATUS             0x00000040
+/* Other bits may be used for device-specific events. */
+
+/*
+ * A name that can be customized for each device; read/write.  Padded with zero
+ * bytes.  Quadlets are byte-swapped.  The encoding is whatever the host driver
+ * happens to be using.
+ */
+#define GLOBAL_NICK_NAME               0x00c
+#define  NICK_NAME_SIZE                        64
+
+/*
+ * The current sample rate and clock source; read/write.  Whether a clock
+ * source or sample rate is supported is device-specific; the internal clock
+ * source is always available.  Low/mid/high = up to 48/96/192 kHz.  This
+ * register can be changed even while streams are running.
+ */
+#define GLOBAL_CLOCK_SELECT            0x04c
+#define  CLOCK_SOURCE_MASK             0x000000ff
+#define  CLOCK_SOURCE_AES1             0x00000000
+#define  CLOCK_SOURCE_AES2             0x00000001
+#define  CLOCK_SOURCE_AES3             0x00000002
+#define  CLOCK_SOURCE_AES4             0x00000003
+#define  CLOCK_SOURCE_AES_ANY          0x00000004
+#define  CLOCK_SOURCE_ADAT             0x00000005
+#define  CLOCK_SOURCE_TDIF             0x00000006
+#define  CLOCK_SOURCE_WC               0x00000007
+#define  CLOCK_SOURCE_ARX1             0x00000008
+#define  CLOCK_SOURCE_ARX2             0x00000009
+#define  CLOCK_SOURCE_ARX3             0x0000000a
+#define  CLOCK_SOURCE_ARX4             0x0000000b
+#define  CLOCK_SOURCE_INTERNAL         0x0000000c
+#define  CLOCK_RATE_MASK               0x0000ff00
+#define  CLOCK_RATE_32000              0x00000000
+#define  CLOCK_RATE_44100              0x00000100
+#define  CLOCK_RATE_48000              0x00000200
+#define  CLOCK_RATE_88200              0x00000300
+#define  CLOCK_RATE_96000              0x00000400
+#define  CLOCK_RATE_176400             0x00000500
+#define  CLOCK_RATE_192000             0x00000600
+#define  CLOCK_RATE_ANY_LOW            0x00000700
+#define  CLOCK_RATE_ANY_MID            0x00000800
+#define  CLOCK_RATE_ANY_HIGH           0x00000900
+#define  CLOCK_RATE_NONE               0x00000a00
+#define  CLOCK_RATE_SHIFT              8
+
+/*
+ * Enable streaming; read/write.  Writing a non-zero value (re)starts all
+ * streams that have a valid iso channel set; zero stops all streams.  The
+ * streams' parameters must be configured before starting.  This register is
+ * automatically cleared on a bus reset.
+ */
+#define GLOBAL_ENABLE                  0x050
+
+/*
+ * Status of the sample clock; read-only.
+ */
+#define GLOBAL_STATUS                  0x054
+/* The current clock source is locked. */
+#define  STATUS_SOURCE_LOCKED          0x00000001
+/* The actual sample rate; CLOCK_RATE_32000-_192000 or _NONE. */
+#define  STATUS_NOMINAL_RATE_MASK      0x0000ff00
+
+/*
+ * Status of all clock sources; read-only.
+ */
+#define GLOBAL_EXTENDED_STATUS         0x058
+/*
+ * The _LOCKED bits always show the current status; any change generates
+ * a notification.
+ */
+#define  EXT_STATUS_AES1_LOCKED                0x00000001
+#define  EXT_STATUS_AES2_LOCKED                0x00000002
+#define  EXT_STATUS_AES3_LOCKED                0x00000004
+#define  EXT_STATUS_AES4_LOCKED                0x00000008
+#define  EXT_STATUS_ADAT_LOCKED                0x00000010
+#define  EXT_STATUS_TDIF_LOCKED                0x00000020
+#define  EXT_STATUS_ARX1_LOCKED                0x00000040
+#define  EXT_STATUS_ARX2_LOCKED                0x00000080
+#define  EXT_STATUS_ARX3_LOCKED                0x00000100
+#define  EXT_STATUS_ARX4_LOCKED                0x00000200
+#define  EXT_STATUS_WC_LOCKED          0x00000400
+/*
+ * The _SLIP bits do not generate notifications; a set bit indicates that an
+ * error occurred since the last time when this register was read with
+ * a quadlet read transaction.
+ */
+#define  EXT_STATUS_AES1_SLIP          0x00010000
+#define  EXT_STATUS_AES2_SLIP          0x00020000
+#define  EXT_STATUS_AES3_SLIP          0x00040000
+#define  EXT_STATUS_AES4_SLIP          0x00080000
+#define  EXT_STATUS_ADAT_SLIP          0x00100000
+#define  EXT_STATUS_TDIF_SLIP          0x00200000
+#define  EXT_STATUS_ARX1_SLIP          0x00400000
+#define  EXT_STATUS_ARX2_SLIP          0x00800000
+#define  EXT_STATUS_ARX3_SLIP          0x01000000
+#define  EXT_STATUS_ARX4_SLIP          0x02000000
+#define  EXT_STATUS_WC_SLIP            0x04000000
+
+/*
+ * The measured rate of the current clock source, in Hz; read-only.
+ */
+#define GLOBAL_SAMPLE_RATE             0x05c
+
+/*
+ * The version of the DICE driver specification that this device conforms to;
+ * read-only.
+ */
+#define GLOBAL_VERSION                 0x060
+
+/* Some old firmware versions do not have the following global registers: */
+
+/*
+ * Supported sample rates and clock sources; read-only.
+ */
+#define GLOBAL_CLOCK_CAPABILITIES      0x064
+#define  CLOCK_CAP_RATE_32000          0x00000001
+#define  CLOCK_CAP_RATE_44100          0x00000002
+#define  CLOCK_CAP_RATE_48000          0x00000004
+#define  CLOCK_CAP_RATE_88200          0x00000008
+#define  CLOCK_CAP_RATE_96000          0x00000010
+#define  CLOCK_CAP_RATE_176400         0x00000020
+#define  CLOCK_CAP_RATE_192000         0x00000040
+#define  CLOCK_CAP_SOURCE_AES1         0x00010000
+#define  CLOCK_CAP_SOURCE_AES2         0x00020000
+#define  CLOCK_CAP_SOURCE_AES3         0x00040000
+#define  CLOCK_CAP_SOURCE_AES4         0x00080000
+#define  CLOCK_CAP_SOURCE_AES_ANY      0x00100000
+#define  CLOCK_CAP_SOURCE_ADAT         0x00200000
+#define  CLOCK_CAP_SOURCE_TDIF         0x00400000
+#define  CLOCK_CAP_SOURCE_WC           0x00800000
+#define  CLOCK_CAP_SOURCE_ARX1         0x01000000
+#define  CLOCK_CAP_SOURCE_ARX2         0x02000000
+#define  CLOCK_CAP_SOURCE_ARX3         0x04000000
+#define  CLOCK_CAP_SOURCE_ARX4         0x08000000
+#define  CLOCK_CAP_SOURCE_INTERNAL     0x10000000
+
+/*
+ * Names of all clock sources; read-only.  Quadlets are byte-swapped.  Names
+ * are separated with one backslash, the list is terminated with two
+ * backslashes.  Unused clock sources are included.
+ */
+#define GLOBAL_CLOCK_SOURCE_NAMES      0x068
+#define  CLOCK_SOURCE_NAMES_SIZE       256
+
+/*
+ * Capture stream settings.  This section includes the number/size registers
+ * and the registers of all streams.
+ */
+
+/*
+ * The number of supported capture streams; read-only.
+ */
+#define TX_NUMBER                      0x000
+
+/*
+ * The size of one stream's register block, in quadlets; read-only.  The
+ * registers of the first stream follow immediately afterwards; the registers
+ * of the following streams are offset by this register's value.
+ */
+#define TX_SIZE                                0x004
+
+/*
+ * The isochronous channel number on which packets are sent, or -1 if the
+ * stream is not to be used; read/write.
+ */
+#define TX_ISOCHRONOUS                 0x008
+
+/*
+ * The number of audio channels; read-only.  There will be one quadlet per
+ * channel; the first channel is the first quadlet in a data block.
+ */
+#define TX_NUMBER_AUDIO                        0x00c
+
+/*
+ * The number of MIDI ports, 0-8; read-only.  If > 0, there will be one
+ * additional quadlet in each data block, following the audio quadlets.
+ */
+#define TX_NUMBER_MIDI                 0x010
+
+/*
+ * The speed at which the packets are sent, SCODE_100-_400; read/write.
+ */
+#define TX_SPEED                       0x014
+
+/*
+ * Names of all audio channels; read-only.  Quadlets are byte-swapped.  Names
+ * are separated with one backslash, the list is terminated with two
+ * backslashes.
+ */
+#define TX_NAMES                       0x018
+#define  TX_NAMES_SIZE                 256
+
+/*
+ * Audio IEC60958 capabilities; read-only.  Bitmask with one bit per audio
+ * channel.
+ */
+#define TX_AC3_CAPABILITIES            0x118
+
+/*
+ * Send audio data with IEC60958 label; read/write.  Bitmask with one bit per
+ * audio channel.  This register can be changed even while the stream is
+ * running.
+ */
+#define TX_AC3_ENABLE                  0x11c
+
+/*
+ * Playback stream settings.  This section includes the number/size registers
+ * and the registers of all streams.
+ */
+
+/*
+ * The number of supported playback streams; read-only.
+ */
+#define RX_NUMBER                      0x000
+
+/*
+ * The size of one stream's register block, in quadlets; read-only.  The
+ * registers of the first stream follow immediately afterwards; the registers
+ * of the following streams are offset by this register's value.
+ */
+#define RX_SIZE                                0x004
+
+/*
+ * The isochronous channel number on which packets are received, or -1 if the
+ * stream is not to be used; read/write.
+ */
+#define RX_ISOCHRONOUS                 0x008
+
+/*
+ * Index of first quadlet to be interpreted; read/write.  If > 0, that many
+ * quadlets at the beginning of each data block will be ignored, and all the
+ * audio and MIDI quadlets will follow.
+ */
+#define RX_SEQ_START                   0x00c
+
+/*
+ * The number of audio channels; read-only.  There will be one quadlet per
+ * channel.
+ */
+#define RX_NUMBER_AUDIO                        0x010
+
+/*
+ * The number of MIDI ports, 0-8; read-only.  If > 0, there will be one
+ * additional quadlet in each data block, following the audio quadlets.
+ */
+#define RX_NUMBER_MIDI                 0x014
+
+/*
+ * Names of all audio channels; read-only.  Quadlets are byte-swapped.  Names
+ * are separated with one backslash, the list is terminated with two
+ * backslashes.
+ */
+#define RX_NAMES                       0x018
+#define  RX_NAMES_SIZE                 256
+
+/*
+ * Audio IEC60958 capabilities; read-only.  Bitmask with one bit per audio
+ * channel.
+ */
+#define RX_AC3_CAPABILITIES            0x118
+
+/*
+ * Receive audio data with IEC60958 label; read/write.  Bitmask with one bit
+ * per audio channel.  This register can be changed even while the stream is
+ * running.
+ */
+#define RX_AC3_ENABLE                  0x11c
+
+/*
+ * Extended synchronization information.
+ * This section can be read completely with a block read request.
+ */
+
+/*
+ * Current clock source; read-only.
+ */
+#define EXT_SYNC_CLOCK_SOURCE          0x000
+
+/*
+ * Clock source is locked (boolean); read-only.
+ */
+#define EXT_SYNC_LOCKED                        0x004
+
+/*
+ * Current sample rate (CLOCK_RATE_* >> CLOCK_RATE_SHIFT), _32000-_192000 or
+ * _NONE; read-only.
+ */
+#define EXT_SYNC_RATE                  0x008
+
+/*
+ * ADAT user data bits; read-only.
+ */
+#define EXT_SYNC_ADAT_USER_DATA                0x00c
+/* The data bits, if available. */
+#define  ADAT_USER_DATA_MASK           0x0f
+/* The data bits are not available. */
+#define  ADAT_USER_DATA_NO_DATA                0x10
+
+#endif
diff --git a/sound/firewire/dice.c b/sound/firewire/dice.c
new file mode 100644 (file)
index 0000000..6feee66
--- /dev/null
@@ -0,0 +1,1494 @@
+/*
+ * TC Applied Technologies Digital Interface Communications Engine driver
+ *
+ * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
+ * Licensed under the terms of the GNU General Public License, version 2.
+ */
+
+#include <linux/compat.h>
+#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/firewire.h>
+#include <linux/firewire-constants.h>
+#include <linux/jiffies.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/wait.h>
+#include <sound/control.h>
+#include <sound/core.h>
+#include <sound/firewire.h>
+#include <sound/hwdep.h>
+#include <sound/info.h>
+#include <sound/initval.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include "amdtp.h"
+#include "iso-resources.h"
+#include "lib.h"
+#include "dice-interface.h"
+
+
+struct dice {
+       struct snd_card *card;
+       struct fw_unit *unit;
+       spinlock_t lock;
+       struct mutex mutex;
+       unsigned int global_offset;
+       unsigned int rx_offset;
+       unsigned int clock_caps;
+       unsigned int rx_channels[3];
+       unsigned int rx_midi_ports[3];
+       struct fw_address_handler notification_handler;
+       int owner_generation;
+       int dev_lock_count; /* > 0 driver, < 0 userspace */
+       bool dev_lock_changed;
+       bool global_enabled;
+       struct completion clock_accepted;
+       wait_queue_head_t hwdep_wait;
+       u32 notification_bits;
+       struct fw_iso_resources resources;
+       struct amdtp_out_stream stream;
+};
+
+MODULE_DESCRIPTION("DICE driver");
+MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
+MODULE_LICENSE("GPL v2");
+
+static const unsigned int dice_rates[] = {
+       /* mode 0 */
+       [0] =  32000,
+       [1] =  44100,
+       [2] =  48000,
+       /* mode 1 */
+       [3] =  88200,
+       [4] =  96000,
+       /* mode 2 */
+       [5] = 176400,
+       [6] = 192000,
+};
+
+static unsigned int rate_to_index(unsigned int rate)
+{
+       unsigned int i;
+
+       for (i = 0; i < ARRAY_SIZE(dice_rates); ++i)
+               if (dice_rates[i] == rate)
+                       return i;
+
+       return 0;
+}
+
+static unsigned int rate_index_to_mode(unsigned int rate_index)
+{
+       return ((int)rate_index - 1) / 2;
+}
+
+static void dice_lock_changed(struct dice *dice)
+{
+       dice->dev_lock_changed = true;
+       wake_up(&dice->hwdep_wait);
+}
+
+static int dice_try_lock(struct dice *dice)
+{
+       int err;
+
+       spin_lock_irq(&dice->lock);
+
+       if (dice->dev_lock_count < 0) {
+               err = -EBUSY;
+               goto out;
+       }
+
+       if (dice->dev_lock_count++ == 0)
+               dice_lock_changed(dice);
+       err = 0;
+
+out:
+       spin_unlock_irq(&dice->lock);
+
+       return err;
+}
+
+static void dice_unlock(struct dice *dice)
+{
+       spin_lock_irq(&dice->lock);
+
+       if (WARN_ON(dice->dev_lock_count <= 0))
+               goto out;
+
+       if (--dice->dev_lock_count == 0)
+               dice_lock_changed(dice);
+
+out:
+       spin_unlock_irq(&dice->lock);
+}
+
+static inline u64 global_address(struct dice *dice, unsigned int offset)
+{
+       return DICE_PRIVATE_SPACE + dice->global_offset + offset;
+}
+
+// TODO: rx index
+static inline u64 rx_address(struct dice *dice, unsigned int offset)
+{
+       return DICE_PRIVATE_SPACE + dice->rx_offset + offset;
+}
+
+static int dice_owner_set(struct dice *dice)
+{
+       struct fw_device *device = fw_parent_device(dice->unit);
+       __be64 *buffer;
+       int err, errors = 0;
+
+       buffer = kmalloc(2 * 8, GFP_KERNEL);
+       if (!buffer)
+               return -ENOMEM;
+
+       for (;;) {
+               buffer[0] = cpu_to_be64(OWNER_NO_OWNER);
+               buffer[1] = cpu_to_be64(
+                       ((u64)device->card->node_id << OWNER_NODE_SHIFT) |
+                       dice->notification_handler.offset);
+
+               dice->owner_generation = device->generation;
+               smp_rmb(); /* node_id vs. generation */
+               err = snd_fw_transaction(dice->unit,
+                                        TCODE_LOCK_COMPARE_SWAP,
+                                        global_address(dice, GLOBAL_OWNER),
+                                        buffer, 2 * 8,
+                                        FW_FIXED_GENERATION |
+                                                       dice->owner_generation);
+
+               if (err == 0) {
+                       if (buffer[0] != cpu_to_be64(OWNER_NO_OWNER)) {
+                               dev_err(&dice->unit->device,
+                                       "device is already in use\n");
+                               err = -EBUSY;
+                       }
+                       break;
+               }
+               if (err != -EAGAIN || ++errors >= 3)
+                       break;
+
+               msleep(20);
+       }
+
+       kfree(buffer);
+
+       return err;
+}
+
+static int dice_owner_update(struct dice *dice)
+{
+       struct fw_device *device = fw_parent_device(dice->unit);
+       __be64 *buffer;
+       int err;
+
+       if (dice->owner_generation == -1)
+               return 0;
+
+       buffer = kmalloc(2 * 8, GFP_KERNEL);
+       if (!buffer)
+               return -ENOMEM;
+
+       buffer[0] = cpu_to_be64(OWNER_NO_OWNER);
+       buffer[1] = cpu_to_be64(
+               ((u64)device->card->node_id << OWNER_NODE_SHIFT) |
+               dice->notification_handler.offset);
+
+       dice->owner_generation = device->generation;
+       smp_rmb(); /* node_id vs. generation */
+       err = snd_fw_transaction(dice->unit, TCODE_LOCK_COMPARE_SWAP,
+                                global_address(dice, GLOBAL_OWNER),
+                                buffer, 2 * 8,
+                                FW_FIXED_GENERATION | dice->owner_generation);
+
+       if (err == 0) {
+               if (buffer[0] != cpu_to_be64(OWNER_NO_OWNER)) {
+                       dev_err(&dice->unit->device,
+                               "device is already in use\n");
+                       err = -EBUSY;
+               }
+       } else if (err == -EAGAIN) {
+               err = 0; /* try again later */
+       }
+
+       kfree(buffer);
+
+       if (err < 0)
+               dice->owner_generation = -1;
+
+       return err;
+}
+
+static void dice_owner_clear(struct dice *dice)
+{
+       struct fw_device *device = fw_parent_device(dice->unit);
+       __be64 *buffer;
+
+       buffer = kmalloc(2 * 8, GFP_KERNEL);
+       if (!buffer)
+               return;
+
+       buffer[0] = cpu_to_be64(
+               ((u64)device->card->node_id << OWNER_NODE_SHIFT) |
+               dice->notification_handler.offset);
+       buffer[1] = cpu_to_be64(OWNER_NO_OWNER);
+       snd_fw_transaction(dice->unit, TCODE_LOCK_COMPARE_SWAP,
+                          global_address(dice, GLOBAL_OWNER),
+                          buffer, 2 * 8, FW_QUIET |
+                          FW_FIXED_GENERATION | dice->owner_generation);
+
+       kfree(buffer);
+
+       dice->owner_generation = -1;
+}
+
+static int dice_enable_set(struct dice *dice)
+{
+       __be32 value;
+       int err;
+
+       value = cpu_to_be32(1);
+       err = snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST,
+                                global_address(dice, GLOBAL_ENABLE),
+                                &value, 4,
+                                FW_FIXED_GENERATION | dice->owner_generation);
+       if (err < 0)
+               return err;
+
+       dice->global_enabled = true;
+
+       return 0;
+}
+
+static void dice_enable_clear(struct dice *dice)
+{
+       __be32 value;
+
+       if (!dice->global_enabled)
+               return;
+
+       value = 0;
+       snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST,
+                          global_address(dice, GLOBAL_ENABLE),
+                          &value, 4, FW_QUIET |
+                          FW_FIXED_GENERATION | dice->owner_generation);
+
+       dice->global_enabled = false;
+}
+
+static void dice_notification(struct fw_card *card, struct fw_request *request,
+                             int tcode, int destination, int source,
+                             int generation, unsigned long long offset,
+                             void *data, size_t length, void *callback_data)
+{
+       struct dice *dice = callback_data;
+       u32 bits;
+       unsigned long flags;
+
+       if (tcode != TCODE_WRITE_QUADLET_REQUEST) {
+               fw_send_response(card, request, RCODE_TYPE_ERROR);
+               return;
+       }
+       if ((offset & 3) != 0) {
+               fw_send_response(card, request, RCODE_ADDRESS_ERROR);
+               return;
+       }
+
+       bits = be32_to_cpup(data);
+
+       spin_lock_irqsave(&dice->lock, flags);
+       dice->notification_bits |= bits;
+       spin_unlock_irqrestore(&dice->lock, flags);
+
+       fw_send_response(card, request, RCODE_COMPLETE);
+
+       if (bits & NOTIFY_CLOCK_ACCEPTED)
+               complete(&dice->clock_accepted);
+       wake_up(&dice->hwdep_wait);
+}
+
+static int dice_rate_constraint(struct snd_pcm_hw_params *params,
+                               struct snd_pcm_hw_rule *rule)
+{
+       struct dice *dice = rule->private;
+       const struct snd_interval *channels =
+               hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+       struct snd_interval *rate =
+               hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+       struct snd_interval allowed_rates = {
+               .min = UINT_MAX, .max = 0, .integer = 1
+       };
+       unsigned int i, mode;
+
+       for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) {
+               mode = rate_index_to_mode(i);
+               if ((dice->clock_caps & (1 << i)) &&
+                   snd_interval_test(channels, dice->rx_channels[mode])) {
+                       allowed_rates.min = min(allowed_rates.min,
+                                               dice_rates[i]);
+                       allowed_rates.max = max(allowed_rates.max,
+                                               dice_rates[i]);
+               }
+       }
+
+       return snd_interval_refine(rate, &allowed_rates);
+}
+
+static int dice_channels_constraint(struct snd_pcm_hw_params *params,
+                                   struct snd_pcm_hw_rule *rule)
+{
+       struct dice *dice = rule->private;
+       const struct snd_interval *rate =
+               hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_RATE);
+       struct snd_interval *channels =
+               hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+       struct snd_interval allowed_channels = {
+               .min = UINT_MAX, .max = 0, .integer = 1
+       };
+       unsigned int i, mode;
+
+       for (i = 0; i < ARRAY_SIZE(dice_rates); ++i)
+               if ((dice->clock_caps & (1 << i)) &&
+                   snd_interval_test(rate, dice_rates[i])) {
+                       mode = rate_index_to_mode(i);
+                       allowed_channels.min = min(allowed_channels.min,
+                                                  dice->rx_channels[mode]);
+                       allowed_channels.max = max(allowed_channels.max,
+                                                  dice->rx_channels[mode]);
+               }
+
+       return snd_interval_refine(channels, &allowed_channels);
+}
+
+static int dice_open(struct snd_pcm_substream *substream)
+{
+       static const struct snd_pcm_hardware hardware = {
+               .info = SNDRV_PCM_INFO_MMAP |
+                       SNDRV_PCM_INFO_MMAP_VALID |
+                       SNDRV_PCM_INFO_BATCH |
+                       SNDRV_PCM_INFO_INTERLEAVED |
+                       SNDRV_PCM_INFO_BLOCK_TRANSFER,
+               .formats = AMDTP_OUT_PCM_FORMAT_BITS,
+               .channels_min = UINT_MAX,
+               .channels_max = 0,
+               .buffer_bytes_max = 16 * 1024 * 1024,
+               .period_bytes_min = 1,
+               .period_bytes_max = UINT_MAX,
+               .periods_min = 1,
+               .periods_max = UINT_MAX,
+       };
+       struct dice *dice = substream->private_data;
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       unsigned int i;
+       int err;
+
+       err = dice_try_lock(dice);
+       if (err < 0)
+               goto error;
+
+       runtime->hw = hardware;
+
+       for (i = 0; i < ARRAY_SIZE(dice_rates); ++i)
+               if (dice->clock_caps & (1 << i))
+                       runtime->hw.rates |=
+                               snd_pcm_rate_to_rate_bit(dice_rates[i]);
+       snd_pcm_limit_hw_rates(runtime);
+
+       for (i = 0; i < 3; ++i)
+               if (dice->rx_channels[i]) {
+                       runtime->hw.channels_min = min(runtime->hw.channels_min,
+                                                      dice->rx_channels[i]);
+                       runtime->hw.channels_max = max(runtime->hw.channels_max,
+                                                      dice->rx_channels[i]);
+               }
+
+       err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+                                 dice_rate_constraint, dice,
+                                 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
+       if (err < 0)
+               goto err_lock;
+       err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
+                                 dice_channels_constraint, dice,
+                                 SNDRV_PCM_HW_PARAM_RATE, -1);
+       if (err < 0)
+               goto err_lock;
+
+       err = snd_pcm_hw_constraint_step(runtime, 0,
+                                        SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32);
+       if (err < 0)
+               goto err_lock;
+       err = snd_pcm_hw_constraint_step(runtime, 0,
+                                        SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32);
+       if (err < 0)
+               goto err_lock;
+
+       err = snd_pcm_hw_constraint_minmax(runtime,
+                                          SNDRV_PCM_HW_PARAM_PERIOD_TIME,
+                                          5000, UINT_MAX);
+       if (err < 0)
+               goto err_lock;
+
+       err = snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
+       if (err < 0)
+               goto err_lock;
+
+       return 0;
+
+err_lock:
+       dice_unlock(dice);
+error:
+       return err;
+}
+
+static int dice_close(struct snd_pcm_substream *substream)
+{
+       struct dice *dice = substream->private_data;
+
+       dice_unlock(dice);
+
+       return 0;
+}
+
+static int dice_stream_start_packets(struct dice *dice)
+{
+       int err;
+
+       if (amdtp_out_stream_running(&dice->stream))
+               return 0;
+
+       err = amdtp_out_stream_start(&dice->stream, dice->resources.channel,
+                                    fw_parent_device(dice->unit)->max_speed);
+       if (err < 0)
+               return err;
+
+       err = dice_enable_set(dice);
+       if (err < 0) {
+               amdtp_out_stream_stop(&dice->stream);
+               return err;
+       }
+
+       return 0;
+}
+
+static int dice_stream_start(struct dice *dice)
+{
+       __be32 channel;
+       int err;
+
+       if (!dice->resources.allocated) {
+               err = fw_iso_resources_allocate(&dice->resources,
+                               amdtp_out_stream_get_max_payload(&dice->stream),
+                               fw_parent_device(dice->unit)->max_speed);
+               if (err < 0)
+                       goto error;
+
+               channel = cpu_to_be32(dice->resources.channel);
+               err = snd_fw_transaction(dice->unit,
+                                        TCODE_WRITE_QUADLET_REQUEST,
+                                        rx_address(dice, RX_ISOCHRONOUS),
+                                        &channel, 4, 0);
+               if (err < 0)
+                       goto err_resources;
+       }
+
+       err = dice_stream_start_packets(dice);
+       if (err < 0)
+               goto err_rx_channel;
+
+       return 0;
+
+err_rx_channel:
+       channel = cpu_to_be32((u32)-1);
+       snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST,
+                          rx_address(dice, RX_ISOCHRONOUS), &channel, 4, 0);
+err_resources:
+       fw_iso_resources_free(&dice->resources);
+error:
+       return err;
+}
+
+static void dice_stream_stop_packets(struct dice *dice)
+{
+       if (amdtp_out_stream_running(&dice->stream)) {
+               dice_enable_clear(dice);
+               amdtp_out_stream_stop(&dice->stream);
+       }
+}
+
+static void dice_stream_stop(struct dice *dice)
+{
+       __be32 channel;
+
+       dice_stream_stop_packets(dice);
+
+       if (!dice->resources.allocated)
+               return;
+
+       channel = cpu_to_be32((u32)-1);
+       snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST,
+                          rx_address(dice, RX_ISOCHRONOUS), &channel, 4, 0);
+
+       fw_iso_resources_free(&dice->resources);
+}
+
+static int dice_change_rate(struct dice *dice, unsigned int clock_rate)
+{
+       __be32 value;
+       int err;
+
+       INIT_COMPLETION(dice->clock_accepted);
+
+       value = cpu_to_be32(clock_rate | CLOCK_SOURCE_ARX1);
+       err = snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST,
+                                global_address(dice, GLOBAL_CLOCK_SELECT),
+                                &value, 4, 0);
+       if (err < 0)
+               return err;
+
+       if (!wait_for_completion_timeout(&dice->clock_accepted,
+                                        msecs_to_jiffies(100)))
+               dev_warn(&dice->unit->device, "clock change timed out\n");
+
+       return 0;
+}
+
+static int dice_hw_params(struct snd_pcm_substream *substream,
+                         struct snd_pcm_hw_params *hw_params)
+{
+       struct dice *dice = substream->private_data;
+       unsigned int rate_index, mode;
+       int err;
+
+       mutex_lock(&dice->mutex);
+       dice_stream_stop(dice);
+       mutex_unlock(&dice->mutex);
+
+       err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
+                                              params_buffer_bytes(hw_params));
+       if (err < 0)
+               return err;
+
+       rate_index = rate_to_index(params_rate(hw_params));
+       err = dice_change_rate(dice, rate_index << CLOCK_RATE_SHIFT);
+       if (err < 0)
+               return err;
+
+       mode = rate_index_to_mode(rate_index);
+       amdtp_out_stream_set_parameters(&dice->stream,
+                                       params_rate(hw_params),
+                                       params_channels(hw_params),
+                                       dice->rx_midi_ports[mode]);
+       amdtp_out_stream_set_pcm_format(&dice->stream,
+                                       params_format(hw_params));
+
+       return 0;
+}
+
+static int dice_hw_free(struct snd_pcm_substream *substream)
+{
+       struct dice *dice = substream->private_data;
+
+       mutex_lock(&dice->mutex);
+       dice_stream_stop(dice);
+       mutex_unlock(&dice->mutex);
+
+       return snd_pcm_lib_free_vmalloc_buffer(substream);
+}
+
+static int dice_prepare(struct snd_pcm_substream *substream)
+{
+       struct dice *dice = substream->private_data;
+       int err;
+
+       mutex_lock(&dice->mutex);
+
+       if (amdtp_out_streaming_error(&dice->stream))
+               dice_stream_stop_packets(dice);
+
+       err = dice_stream_start(dice);
+       if (err < 0) {
+               mutex_unlock(&dice->mutex);
+               return err;
+       }
+
+       mutex_unlock(&dice->mutex);
+
+       amdtp_out_stream_pcm_prepare(&dice->stream);
+
+       return 0;
+}
+
+static int dice_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+       struct dice *dice = substream->private_data;
+       struct snd_pcm_substream *pcm;
+
+       switch (cmd) {
+       case SNDRV_PCM_TRIGGER_START:
+               pcm = substream;
+               break;
+       case SNDRV_PCM_TRIGGER_STOP:
+               pcm = NULL;
+               break;
+       default:
+               return -EINVAL;
+       }
+       amdtp_out_stream_pcm_trigger(&dice->stream, pcm);
+
+       return 0;
+}
+
+static snd_pcm_uframes_t dice_pointer(struct snd_pcm_substream *substream)
+{
+       struct dice *dice = substream->private_data;
+
+       return amdtp_out_stream_pcm_pointer(&dice->stream);
+}
+
+static int dice_create_pcm(struct dice *dice)
+{
+       static struct snd_pcm_ops ops = {
+               .open      = dice_open,
+               .close     = dice_close,
+               .ioctl     = snd_pcm_lib_ioctl,
+               .hw_params = dice_hw_params,
+               .hw_free   = dice_hw_free,
+               .prepare   = dice_prepare,
+               .trigger   = dice_trigger,
+               .pointer   = dice_pointer,
+               .page      = snd_pcm_lib_get_vmalloc_page,
+               .mmap      = snd_pcm_lib_mmap_vmalloc,
+       };
+       struct snd_pcm *pcm;
+       int err;
+
+       err = snd_pcm_new(dice->card, "DICE", 0, 1, 0, &pcm);
+       if (err < 0)
+               return err;
+       pcm->private_data = dice;
+       strcpy(pcm->name, dice->card->shortname);
+       pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->ops = &ops;
+
+       return 0;
+}
+
+static long dice_hwdep_read(struct snd_hwdep *hwdep, char __user *buf,
+                           long count, loff_t *offset)
+{
+       struct dice *dice = hwdep->private_data;
+       DEFINE_WAIT(wait);
+       union snd_firewire_event event;
+
+       spin_lock_irq(&dice->lock);
+
+       while (!dice->dev_lock_changed && dice->notification_bits == 0) {
+               prepare_to_wait(&dice->hwdep_wait, &wait, TASK_INTERRUPTIBLE);
+               spin_unlock_irq(&dice->lock);
+               schedule();
+               finish_wait(&dice->hwdep_wait, &wait);
+               if (signal_pending(current))
+                       return -ERESTARTSYS;
+               spin_lock_irq(&dice->lock);
+       }
+
+       memset(&event, 0, sizeof(event));
+       if (dice->dev_lock_changed) {
+               event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS;
+               event.lock_status.status = dice->dev_lock_count > 0;
+               dice->dev_lock_changed = false;
+
+               count = min(count, (long)sizeof(event.lock_status));
+       } else {
+               event.dice_notification.type = SNDRV_FIREWIRE_EVENT_DICE_NOTIFICATION;
+               event.dice_notification.notification = dice->notification_bits;
+               dice->notification_bits = 0;
+
+               count = min(count, (long)sizeof(event.dice_notification));
+       }
+
+       spin_unlock_irq(&dice->lock);
+
+       if (copy_to_user(buf, &event, count))
+               return -EFAULT;
+
+       return count;
+}
+
+static unsigned int dice_hwdep_poll(struct snd_hwdep *hwdep, struct file *file,
+                                   poll_table *wait)
+{
+       struct dice *dice = hwdep->private_data;
+       unsigned int events;
+
+       poll_wait(file, &dice->hwdep_wait, wait);
+
+       spin_lock_irq(&dice->lock);
+       if (dice->dev_lock_changed || dice->notification_bits != 0)
+               events = POLLIN | POLLRDNORM;
+       else
+               events = 0;
+       spin_unlock_irq(&dice->lock);
+
+       return events;
+}
+
+static int dice_hwdep_get_info(struct dice *dice, void __user *arg)
+{
+       struct fw_device *dev = fw_parent_device(dice->unit);
+       struct snd_firewire_get_info info;
+
+       memset(&info, 0, sizeof(info));
+       info.type = SNDRV_FIREWIRE_TYPE_DICE;
+       info.card = dev->card->index;
+       *(__be32 *)&info.guid[0] = cpu_to_be32(dev->config_rom[3]);
+       *(__be32 *)&info.guid[4] = cpu_to_be32(dev->config_rom[4]);
+       strlcpy(info.device_name, dev_name(&dev->device),
+               sizeof(info.device_name));
+
+       if (copy_to_user(arg, &info, sizeof(info)))
+               return -EFAULT;
+
+       return 0;
+}
+
+static int dice_hwdep_lock(struct dice *dice)
+{
+       int err;
+
+       spin_lock_irq(&dice->lock);
+
+       if (dice->dev_lock_count == 0) {
+               dice->dev_lock_count = -1;
+               err = 0;
+       } else {
+               err = -EBUSY;
+       }
+
+       spin_unlock_irq(&dice->lock);
+
+       return err;
+}
+
+static int dice_hwdep_unlock(struct dice *dice)
+{
+       int err;
+
+       spin_lock_irq(&dice->lock);
+
+       if (dice->dev_lock_count == -1) {
+               dice->dev_lock_count = 0;
+               err = 0;
+       } else {
+               err = -EBADFD;
+       }
+
+       spin_unlock_irq(&dice->lock);
+
+       return err;
+}
+
+static int dice_hwdep_release(struct snd_hwdep *hwdep, struct file *file)
+{
+       struct dice *dice = hwdep->private_data;
+
+       spin_lock_irq(&dice->lock);
+       if (dice->dev_lock_count == -1)
+               dice->dev_lock_count = 0;
+       spin_unlock_irq(&dice->lock);
+
+       return 0;
+}
+
+static int dice_hwdep_ioctl(struct snd_hwdep *hwdep, struct file *file,
+                           unsigned int cmd, unsigned long arg)
+{
+       struct dice *dice = hwdep->private_data;
+
+       switch (cmd) {
+       case SNDRV_FIREWIRE_IOCTL_GET_INFO:
+               return dice_hwdep_get_info(dice, (void __user *)arg);
+       case SNDRV_FIREWIRE_IOCTL_LOCK:
+               return dice_hwdep_lock(dice);
+       case SNDRV_FIREWIRE_IOCTL_UNLOCK:
+               return dice_hwdep_unlock(dice);
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+
+#ifdef CONFIG_COMPAT
+static int dice_hwdep_compat_ioctl(struct snd_hwdep *hwdep, struct file *file,
+                                  unsigned int cmd, unsigned long arg)
+{
+       return dice_hwdep_ioctl(hwdep, file, cmd,
+                               (unsigned long)compat_ptr(arg));
+}
+#else
+#define dice_hwdep_compat_ioctl NULL
+#endif
+
+static int dice_create_hwdep(struct dice *dice)
+{
+       static const struct snd_hwdep_ops ops = {
+               .read         = dice_hwdep_read,
+               .release      = dice_hwdep_release,
+               .poll         = dice_hwdep_poll,
+               .ioctl        = dice_hwdep_ioctl,
+               .ioctl_compat = dice_hwdep_compat_ioctl,
+       };
+       struct snd_hwdep *hwdep;
+       int err;
+
+       err = snd_hwdep_new(dice->card, "DICE", 0, &hwdep);
+       if (err < 0)
+               return err;
+       strcpy(hwdep->name, "DICE");
+       hwdep->iface = SNDRV_HWDEP_IFACE_FW_DICE;
+       hwdep->ops = ops;
+       hwdep->private_data = dice;
+       hwdep->exclusive = true;
+
+       return 0;
+}
+
+static int dice_proc_read_mem(struct dice *dice, void *buffer,
+                             unsigned int offset_q, unsigned int quadlets)
+{
+       unsigned int i;
+       int err;
+
+       err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST,
+                                DICE_PRIVATE_SPACE + 4 * offset_q,
+                                buffer, 4 * quadlets, 0);
+       if (err < 0)
+               return err;
+
+       for (i = 0; i < quadlets; ++i)
+               be32_to_cpus(&((u32 *)buffer)[i]);
+
+       return 0;
+}
+
+static const char *str_from_array(const char *const strs[], unsigned int count,
+                                 unsigned int i)
+{
+       if (i < count)
+               return strs[i];
+       else
+               return "(unknown)";
+}
+
+static void dice_proc_fixup_string(char *s, unsigned int size)
+{
+       unsigned int i;
+
+       for (i = 0; i < size; i += 4)
+               cpu_to_le32s((u32 *)(s + i));
+
+       for (i = 0; i < size - 2; ++i) {
+               if (s[i] == '\0')
+                       return;
+               if (s[i] == '\\' && s[i + 1] == '\\') {
+                       s[i + 2] = '\0';
+                       return;
+               }
+       }
+       s[size - 1] = '\0';
+}
+
+static void dice_proc_read(struct snd_info_entry *entry,
+                          struct snd_info_buffer *buffer)
+{
+       static const char *const section_names[5] = {
+               "global", "tx", "rx", "ext_sync", "unused2"
+       };
+       static const char *const clock_sources[] = {
+               "aes1", "aes2", "aes3", "aes4", "aes", "adat", "tdif",
+               "wc", "arx1", "arx2", "arx3", "arx4", "internal"
+       };
+       static const char *const rates[] = {
+               "32000", "44100", "48000", "88200", "96000", "176400", "192000",
+               "any low", "any mid", "any high", "none"
+       };
+       struct dice *dice = entry->private_data;
+       u32 sections[ARRAY_SIZE(section_names) * 2];
+       struct {
+               u32 number;
+               u32 size;
+       } tx_rx_header;
+       union {
+               struct {
+                       u32 owner_hi, owner_lo;
+                       u32 notification;
+                       char nick_name[NICK_NAME_SIZE];
+                       u32 clock_select;
+                       u32 enable;
+                       u32 status;
+                       u32 extended_status;
+                       u32 sample_rate;
+                       u32 version;
+                       u32 clock_caps;
+                       char clock_source_names[CLOCK_SOURCE_NAMES_SIZE];
+               } global;
+               struct {
+                       u32 iso;
+                       u32 number_audio;
+                       u32 number_midi;
+                       u32 speed;
+                       char names[TX_NAMES_SIZE];
+                       u32 ac3_caps;
+                       u32 ac3_enable;
+               } tx;
+               struct {
+                       u32 iso;
+                       u32 seq_start;
+                       u32 number_audio;
+                       u32 number_midi;
+                       char names[RX_NAMES_SIZE];
+                       u32 ac3_caps;
+                       u32 ac3_enable;
+               } rx;
+               struct {
+                       u32 clock_source;
+                       u32 locked;
+                       u32 rate;
+                       u32 adat_user_data;
+               } ext_sync;
+       } buf;
+       unsigned int quadlets, stream, i;
+
+       if (dice_proc_read_mem(dice, sections, 0, ARRAY_SIZE(sections)) < 0)
+               return;
+       snd_iprintf(buffer, "sections:\n");
+       for (i = 0; i < ARRAY_SIZE(section_names); ++i)
+               snd_iprintf(buffer, "  %s: offset %u, size %u\n",
+                           section_names[i],
+                           sections[i * 2], sections[i * 2 + 1]);
+
+       quadlets = min_t(u32, sections[1], sizeof(buf.global) / 4);
+       if (dice_proc_read_mem(dice, &buf.global, sections[0], quadlets) < 0)
+               return;
+       snd_iprintf(buffer, "global:\n");
+       snd_iprintf(buffer, "  owner: %04x:%04x%08x\n",
+                   buf.global.owner_hi >> 16,
+                   buf.global.owner_hi & 0xffff, buf.global.owner_lo);
+       snd_iprintf(buffer, "  notification: %08x\n", buf.global.notification);
+       dice_proc_fixup_string(buf.global.nick_name, NICK_NAME_SIZE);
+       snd_iprintf(buffer, "  nick name: %s\n", buf.global.nick_name);
+       snd_iprintf(buffer, "  clock select: %s %s\n",
+                   str_from_array(clock_sources, ARRAY_SIZE(clock_sources),
+                                  buf.global.clock_select & CLOCK_SOURCE_MASK),
+                   str_from_array(rates, ARRAY_SIZE(rates),
+                                  (buf.global.clock_select & CLOCK_RATE_MASK)
+                                  >> CLOCK_RATE_SHIFT));
+       snd_iprintf(buffer, "  enable: %u\n", buf.global.enable);
+       snd_iprintf(buffer, "  status: %slocked %s\n",
+                   buf.global.status & STATUS_SOURCE_LOCKED ? "" : "un",
+                   str_from_array(rates, ARRAY_SIZE(rates),
+                                  (buf.global.status &
+                                   STATUS_NOMINAL_RATE_MASK)
+                                  >> CLOCK_RATE_SHIFT));
+       snd_iprintf(buffer, "  ext status: %08x\n", buf.global.extended_status);
+       snd_iprintf(buffer, "  sample rate: %u\n", buf.global.sample_rate);
+       snd_iprintf(buffer, "  version: %u.%u.%u.%u\n",
+                   (buf.global.version >> 24) & 0xff,
+                   (buf.global.version >> 16) & 0xff,
+                   (buf.global.version >>  8) & 0xff,
+                   (buf.global.version >>  0) & 0xff);
+       if (quadlets >= 90) {
+               snd_iprintf(buffer, "  clock caps:");
+               for (i = 0; i <= 6; ++i)
+                       if (buf.global.clock_caps & (1 << i))
+                               snd_iprintf(buffer, " %s", rates[i]);
+               for (i = 0; i <= 12; ++i)
+                       if (buf.global.clock_caps & (1 << (16 + i)))
+                               snd_iprintf(buffer, " %s", clock_sources[i]);
+               snd_iprintf(buffer, "\n");
+               dice_proc_fixup_string(buf.global.clock_source_names,
+                                      CLOCK_SOURCE_NAMES_SIZE);
+               snd_iprintf(buffer, "  clock source names: %s\n",
+                           buf.global.clock_source_names);
+       }
+
+       if (dice_proc_read_mem(dice, &tx_rx_header, sections[2], 2) < 0)
+               return;
+       quadlets = min_t(u32, tx_rx_header.size, sizeof(buf.tx));
+       for (stream = 0; stream < tx_rx_header.number; ++stream) {
+               if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 +
+                                      stream * tx_rx_header.size,
+                                      quadlets) < 0)
+                       break;
+               snd_iprintf(buffer, "tx %u:\n", stream);
+               snd_iprintf(buffer, "  iso channel: %d\n", (int)buf.tx.iso);
+               snd_iprintf(buffer, "  audio channels: %u\n",
+                           buf.tx.number_audio);
+               snd_iprintf(buffer, "  midi ports: %u\n", buf.tx.number_midi);
+               snd_iprintf(buffer, "  speed: S%u\n", 100u << buf.tx.speed);
+               if (quadlets >= 68) {
+                       dice_proc_fixup_string(buf.tx.names, TX_NAMES_SIZE);
+                       snd_iprintf(buffer, "  names: %s\n", buf.tx.names);
+               }
+               if (quadlets >= 70) {
+                       snd_iprintf(buffer, "  ac3 caps: %08x\n",
+                                   buf.tx.ac3_caps);
+                       snd_iprintf(buffer, "  ac3 enable: %08x\n",
+                                   buf.tx.ac3_enable);
+               }
+       }
+
+       if (dice_proc_read_mem(dice, &tx_rx_header, sections[4], 2) < 0)
+               return;
+       quadlets = min_t(u32, tx_rx_header.size, sizeof(buf.rx));
+       for (stream = 0; stream < tx_rx_header.number; ++stream) {
+               if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 +
+                                      stream * tx_rx_header.size,
+                                      quadlets) < 0)
+                       break;
+               snd_iprintf(buffer, "rx %u:\n", stream);
+               snd_iprintf(buffer, "  iso channel: %d\n", (int)buf.rx.iso);
+               snd_iprintf(buffer, "  sequence start: %u\n", buf.rx.seq_start);
+               snd_iprintf(buffer, "  audio channels: %u\n",
+                           buf.rx.number_audio);
+               snd_iprintf(buffer, "  midi ports: %u\n", buf.rx.number_midi);
+               if (quadlets >= 68) {
+                       dice_proc_fixup_string(buf.rx.names, RX_NAMES_SIZE);
+                       snd_iprintf(buffer, "  names: %s\n", buf.rx.names);
+               }
+               if (quadlets >= 70) {
+                       snd_iprintf(buffer, "  ac3 caps: %08x\n",
+                                   buf.rx.ac3_caps);
+                       snd_iprintf(buffer, "  ac3 enable: %08x\n",
+                                   buf.rx.ac3_enable);
+               }
+       }
+
+       quadlets = min_t(u32, sections[7], sizeof(buf.ext_sync) / 4);
+       if (quadlets >= 4) {
+               if (dice_proc_read_mem(dice, &buf.ext_sync,
+                                      sections[6], 4) < 0)
+                       return;
+               snd_iprintf(buffer, "ext status:\n");
+               snd_iprintf(buffer, "  clock source: %s\n",
+                           str_from_array(clock_sources,
+                                          ARRAY_SIZE(clock_sources),
+                                          buf.ext_sync.clock_source));
+               snd_iprintf(buffer, "  locked: %u\n", buf.ext_sync.locked);
+               snd_iprintf(buffer, "  rate: %s\n",
+                           str_from_array(rates, ARRAY_SIZE(rates),
+                                          buf.ext_sync.rate));
+               snd_iprintf(buffer, "  adat user data: ");
+               if (buf.ext_sync.adat_user_data & ADAT_USER_DATA_NO_DATA)
+                       snd_iprintf(buffer, "-\n");
+               else
+                       snd_iprintf(buffer, "%x\n",
+                                   buf.ext_sync.adat_user_data);
+       }
+}
+
+static void dice_create_proc(struct dice *dice)
+{
+       struct snd_info_entry *entry;
+
+       if (!snd_card_proc_new(dice->card, "dice", &entry))
+               snd_info_set_text_ops(entry, dice, dice_proc_read);
+}
+
+static void dice_card_free(struct snd_card *card)
+{
+       struct dice *dice = card->private_data;
+
+       amdtp_out_stream_destroy(&dice->stream);
+       fw_core_remove_address_handler(&dice->notification_handler);
+       mutex_destroy(&dice->mutex);
+}
+
+#define OUI_WEISS              0x001c6a
+
+#define DICE_CATEGORY_ID       0x04
+#define WEISS_CATEGORY_ID      0x00
+
+static int dice_interface_check(struct fw_unit *unit)
+{
+       static const int min_values[10] = {
+               10, 0x64 / 4,
+               10, 0x18 / 4,
+               10, 0x18 / 4,
+               0, 0,
+               0, 0,
+       };
+       struct fw_device *device = fw_parent_device(unit);
+       struct fw_csr_iterator it;
+       int key, value, vendor = -1, model = -1, err;
+       unsigned int category, i;
+       __be32 pointers[ARRAY_SIZE(min_values)];
+       __be32 tx_data[4];
+       __be32 version;
+
+       /*
+        * Check that GUID and unit directory are constructed according to DICE
+        * rules, i.e., that the specifier ID is the GUID's OUI, and that the
+        * GUID chip ID consists of the 8-bit category ID, the 10-bit product
+        * ID, and a 22-bit serial number.
+        */
+       fw_csr_iterator_init(&it, unit->directory);
+       while (fw_csr_iterator_next(&it, &key, &value)) {
+               switch (key) {
+               case CSR_SPECIFIER_ID:
+                       vendor = value;
+                       break;
+               case CSR_MODEL:
+                       model = value;
+                       break;
+               }
+       }
+       if (vendor == OUI_WEISS)
+               category = WEISS_CATEGORY_ID;
+       else
+               category = DICE_CATEGORY_ID;
+       if (device->config_rom[3] != ((vendor << 8) | category) ||
+           device->config_rom[4] >> 22 != model)
+               return -ENODEV;
+
+       /*
+        * Check that the sub address spaces exist and are located inside the
+        * private address space.  The minimum values are chosen so that all
+        * minimally required registers are included.
+        */
+       err = snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST,
+                                DICE_PRIVATE_SPACE,
+                                pointers, sizeof(pointers), 0);
+       if (err < 0)
+               return -ENODEV;
+       for (i = 0; i < ARRAY_SIZE(pointers); ++i) {
+               value = be32_to_cpu(pointers[i]);
+               if (value < min_values[i] || value >= 0x40000)
+                       return -ENODEV;
+       }
+
+       /* We support playback only. Let capture devices be handled by FFADO. */
+       err = snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST,
+                                DICE_PRIVATE_SPACE +
+                                be32_to_cpu(pointers[2]) * 4,
+                                tx_data, sizeof(tx_data), 0);
+       if (err < 0 || (tx_data[0] && tx_data[3]))
+               return -ENODEV;
+
+       /*
+        * Check that the implemented DICE driver specification major version
+        * number matches.
+        */
+       err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
+                                DICE_PRIVATE_SPACE +
+                                be32_to_cpu(pointers[0]) * 4 + GLOBAL_VERSION,
+                                &version, 4, 0);
+       if (err < 0)
+               return -ENODEV;
+       if ((version & cpu_to_be32(0xff000000)) != cpu_to_be32(0x01000000)) {
+               dev_err(&unit->device,
+                       "unknown DICE version: 0x%08x\n", be32_to_cpu(version));
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+static int highest_supported_mode_rate(struct dice *dice, unsigned int mode)
+{
+       int i;
+
+       for (i = ARRAY_SIZE(dice_rates) - 1; i >= 0; --i)
+               if ((dice->clock_caps & (1 << i)) &&
+                   rate_index_to_mode(i) == mode)
+                       return i;
+
+       return -1;
+}
+
+static int dice_read_mode_params(struct dice *dice, unsigned int mode)
+{
+       __be32 values[2];
+       int rate_index, err;
+
+       rate_index = highest_supported_mode_rate(dice, mode);
+       if (rate_index < 0) {
+               dice->rx_channels[mode] = 0;
+               dice->rx_midi_ports[mode] = 0;
+               return 0;
+       }
+
+       err = dice_change_rate(dice, rate_index << CLOCK_RATE_SHIFT);
+       if (err < 0)
+               return err;
+
+       err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST,
+                                rx_address(dice, RX_NUMBER_AUDIO),
+                                values, 2 * 4, 0);
+       if (err < 0)
+               return err;
+
+       dice->rx_channels[mode]   = be32_to_cpu(values[0]);
+       dice->rx_midi_ports[mode] = be32_to_cpu(values[1]);
+
+       return 0;
+}
+
+static int dice_read_params(struct dice *dice)
+{
+       __be32 pointers[6];
+       __be32 value;
+       int mode, err;
+
+       err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST,
+                                DICE_PRIVATE_SPACE,
+                                pointers, sizeof(pointers), 0);
+       if (err < 0)
+               return err;
+
+       dice->global_offset = be32_to_cpu(pointers[0]) * 4;
+       dice->rx_offset = be32_to_cpu(pointers[4]) * 4;
+
+       /* some very old firmwares don't tell about their clock support */
+       if (be32_to_cpu(pointers[1]) * 4 >= GLOBAL_CLOCK_CAPABILITIES + 4) {
+               err = snd_fw_transaction(
+                               dice->unit, TCODE_READ_QUADLET_REQUEST,
+                               global_address(dice, GLOBAL_CLOCK_CAPABILITIES),
+                               &value, 4, 0);
+               if (err < 0)
+                       return err;
+               dice->clock_caps = be32_to_cpu(value);
+       } else {
+               /* this should be supported by any device */
+               dice->clock_caps = CLOCK_CAP_RATE_44100 |
+                                  CLOCK_CAP_RATE_48000 |
+                                  CLOCK_CAP_SOURCE_ARX1 |
+                                  CLOCK_CAP_SOURCE_INTERNAL;
+       }
+
+       for (mode = 2; mode >= 0; --mode) {
+               err = dice_read_mode_params(dice, mode);
+               if (err < 0)
+                       return err;
+       }
+
+       return 0;
+}
+
+static void dice_card_strings(struct dice *dice)
+{
+       struct snd_card *card = dice->card;
+       struct fw_device *dev = fw_parent_device(dice->unit);
+       char vendor[32], model[32];
+       unsigned int i;
+       int err;
+
+       strcpy(card->driver, "DICE");
+
+       strcpy(card->shortname, "DICE");
+       BUILD_BUG_ON(NICK_NAME_SIZE < sizeof(card->shortname));
+       err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST,
+                                global_address(dice, GLOBAL_NICK_NAME),
+                                card->shortname, sizeof(card->shortname), 0);
+       if (err >= 0) {
+               /* DICE strings are returned in "always-wrong" endianness */
+               BUILD_BUG_ON(sizeof(card->shortname) % 4 != 0);
+               for (i = 0; i < sizeof(card->shortname); i += 4)
+                       swab32s((u32 *)&card->shortname[i]);
+               card->shortname[sizeof(card->shortname) - 1] = '\0';
+       }
+
+       strcpy(vendor, "?");
+       fw_csr_string(dev->config_rom + 5, CSR_VENDOR, vendor, sizeof(vendor));
+       strcpy(model, "?");
+       fw_csr_string(dice->unit->directory, CSR_MODEL, model, sizeof(model));
+       snprintf(card->longname, sizeof(card->longname),
+                "%s %s (serial %u) at %s, S%d",
+                vendor, model, dev->config_rom[4] & 0x3fffff,
+                dev_name(&dice->unit->device), 100 << dev->max_speed);
+
+       strcpy(card->mixername, "DICE");
+}
+
+static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
+{
+       struct snd_card *card;
+       struct dice *dice;
+       __be32 clock_sel;
+       int err;
+
+       err = dice_interface_check(unit);
+       if (err < 0)
+               return err;
+
+       err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*dice), &card);
+       if (err < 0)
+               return err;
+       snd_card_set_dev(card, &unit->device);
+
+       dice = card->private_data;
+       dice->card = card;
+       spin_lock_init(&dice->lock);
+       mutex_init(&dice->mutex);
+       dice->unit = unit;
+       init_completion(&dice->clock_accepted);
+       init_waitqueue_head(&dice->hwdep_wait);
+
+       dice->notification_handler.length = 4;
+       dice->notification_handler.address_callback = dice_notification;
+       dice->notification_handler.callback_data = dice;
+       err = fw_core_add_address_handler(&dice->notification_handler,
+                                         &fw_high_memory_region);
+       if (err < 0)
+               goto err_mutex;
+
+       err = dice_owner_set(dice);
+       if (err < 0)
+               goto err_notification_handler;
+
+       err = dice_read_params(dice);
+       if (err < 0)
+               goto err_owner;
+
+       err = fw_iso_resources_init(&dice->resources, unit);
+       if (err < 0)
+               goto err_owner;
+       dice->resources.channels_mask = 0x00000000ffffffffuLL;
+
+       err = amdtp_out_stream_init(&dice->stream, unit,
+                                   CIP_BLOCKING | CIP_HI_DUALWIRE);
+       if (err < 0)
+               goto err_resources;
+
+       card->private_free = dice_card_free;
+
+       dice_card_strings(dice);
+
+       err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
+                                global_address(dice, GLOBAL_CLOCK_SELECT),
+                                &clock_sel, 4, 0);
+       if (err < 0)
+               goto error;
+       clock_sel &= cpu_to_be32(~CLOCK_SOURCE_MASK);
+       clock_sel |= cpu_to_be32(CLOCK_SOURCE_ARX1);
+       err = snd_fw_transaction(unit, TCODE_WRITE_QUADLET_REQUEST,
+                                global_address(dice, GLOBAL_CLOCK_SELECT),
+                                &clock_sel, 4, 0);
+       if (err < 0)
+               goto error;
+
+       err = dice_create_pcm(dice);
+       if (err < 0)
+               goto error;
+
+       err = dice_create_hwdep(dice);
+       if (err < 0)
+               goto error;
+
+       dice_create_proc(dice);
+
+       err = snd_card_register(card);
+       if (err < 0)
+               goto error;
+
+       dev_set_drvdata(&unit->device, dice);
+
+       return 0;
+
+err_resources:
+       fw_iso_resources_destroy(&dice->resources);
+err_owner:
+       dice_owner_clear(dice);
+err_notification_handler:
+       fw_core_remove_address_handler(&dice->notification_handler);
+err_mutex:
+       mutex_destroy(&dice->mutex);
+error:
+       snd_card_free(card);
+       return err;
+}
+
+static void dice_remove(struct fw_unit *unit)
+{
+       struct dice *dice = dev_get_drvdata(&unit->device);
+
+       amdtp_out_stream_pcm_abort(&dice->stream);
+
+       snd_card_disconnect(dice->card);
+
+       mutex_lock(&dice->mutex);
+
+       dice_stream_stop(dice);
+       dice_owner_clear(dice);
+
+       mutex_unlock(&dice->mutex);
+
+       snd_card_free_when_closed(dice->card);
+}
+
+static void dice_bus_reset(struct fw_unit *unit)
+{
+       struct dice *dice = dev_get_drvdata(&unit->device);
+
+       /*
+        * On a bus reset, the DICE firmware disables streaming and then goes
+        * off contemplating its own navel for hundreds of milliseconds before
+        * it can react to any of our attempts to reenable streaming.  This
+        * means that we lose synchronization anyway, so we force our streams
+        * to stop so that the application can restart them in an orderly
+        * manner.
+        */
+       amdtp_out_stream_pcm_abort(&dice->stream);
+
+       mutex_lock(&dice->mutex);
+
+       dice->global_enabled = false;
+       dice_stream_stop_packets(dice);
+
+       dice_owner_update(dice);
+
+       fw_iso_resources_update(&dice->resources);
+
+       mutex_unlock(&dice->mutex);
+}
+
+#define DICE_INTERFACE 0x000001
+
+static const struct ieee1394_device_id dice_id_table[] = {
+       {
+               .match_flags = IEEE1394_MATCH_VERSION,
+               .version     = DICE_INTERFACE,
+       },
+       { }
+};
+MODULE_DEVICE_TABLE(ieee1394, dice_id_table);
+
+static struct fw_driver dice_driver = {
+       .driver   = {
+               .owner  = THIS_MODULE,
+               .name   = KBUILD_MODNAME,
+               .bus    = &fw_bus_type,
+       },
+       .probe    = dice_probe,
+       .update   = dice_bus_reset,
+       .remove   = dice_remove,
+       .id_table = dice_id_table,
+};
+
+static int __init alsa_dice_init(void)
+{
+       return driver_register(&dice_driver.driver);
+}
+
+static void __exit alsa_dice_exit(void)
+{
+       driver_unregister(&dice_driver.driver);
+}
+
+module_init(alsa_dice_init);
+module_exit(alsa_dice_exit);
index ec578b5ad8da1f45738b76f714574243db76a1db..860c08073c5924ef1fad28d2a3bfed747f947879 100644 (file)
@@ -90,7 +90,7 @@ int fcp_avc_transaction(struct fw_unit *unit,
                                          : TCODE_WRITE_BLOCK_REQUEST;
                ret = snd_fw_transaction(t.unit, tcode,
                                         CSR_REGISTER_BASE + CSR_FCP_COMMAND,
-                                        (void *)command, command_size);
+                                        (void *)command, command_size, 0);
                if (ret < 0)
                        break;
 
index 58a5afefdc69f39ef6720626ad823b5ae55060c9..fd42e6b315e69d90e39deda16d553fc0baf97395 100644 (file)
@@ -217,7 +217,7 @@ static void isight_packet(struct fw_iso_context *context, u32 cycle,
 
 static int isight_connect(struct isight *isight)
 {
-       int ch, err, rcode, errors = 0;
+       int ch, err;
        __be32 value;
 
 retry_after_bus_reset:
@@ -230,27 +230,19 @@ retry_after_bus_reset:
        }
 
        value = cpu_to_be32(ch | (isight->device->max_speed << SPEED_SHIFT));
-       for (;;) {
-               rcode = fw_run_transaction(
-                               isight->device->card,
-                               TCODE_WRITE_QUADLET_REQUEST,
-                               isight->device->node_id,
-                               isight->resources.generation,
-                               isight->device->max_speed,
-                               isight->audio_base + REG_ISO_TX_CONFIG,
-                               &value, 4);
-               if (rcode == RCODE_COMPLETE) {
-                       return 0;
-               } else if (rcode == RCODE_GENERATION) {
-                       fw_iso_resources_free(&isight->resources);
-                       goto retry_after_bus_reset;
-               } else if (rcode_is_permanent_error(rcode) || ++errors >= 3) {
-                       err = -EIO;
-                       goto err_resources;
-               }
-               msleep(5);
+       err = snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST,
+                                isight->audio_base + REG_ISO_TX_CONFIG,
+                                &value, 4, FW_FIXED_GENERATION |
+                                isight->resources.generation);
+       if (err == -EAGAIN) {
+               fw_iso_resources_free(&isight->resources);
+               goto retry_after_bus_reset;
+       } else if (err < 0) {
+               goto err_resources;
        }
 
+       return 0;
+
 err_resources:
        fw_iso_resources_free(&isight->resources);
 error:
@@ -315,17 +307,19 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
 static int reg_read(struct isight *isight, int offset, __be32 *value)
 {
        return snd_fw_transaction(isight->unit, TCODE_READ_QUADLET_REQUEST,
-                                 isight->audio_base + offset, value, 4);
+                                 isight->audio_base + offset, value, 4, 0);
 }
 
 static int reg_write(struct isight *isight, int offset, __be32 value)
 {
        return snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST,
-                                 isight->audio_base + offset, &value, 4);
+                                 isight->audio_base + offset, &value, 4, 0);
 }
 
 static void isight_stop_streaming(struct isight *isight)
 {
+       __be32 value;
+
        if (!isight->context)
                return;
 
@@ -333,7 +327,10 @@ static void isight_stop_streaming(struct isight *isight)
        fw_iso_context_destroy(isight->context);
        isight->context = NULL;
        fw_iso_resources_free(&isight->resources);
-       reg_write(isight, REG_AUDIO_ENABLE, 0);
+       value = 0;
+       snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST,
+                          isight->audio_base + REG_AUDIO_ENABLE,
+                          &value, 4, FW_QUIET);
 }
 
 static int isight_hw_free(struct snd_pcm_substream *substream)
index 14eb414983720fcc629bb55ae962c43be97e8205..7409edba9f06761b11d8582bd60fb43bcc8a0ff6 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/module.h>
 #include "lib.h"
 
-#define ERROR_RETRY_DELAY_MS   5
+#define ERROR_RETRY_DELAY_MS   20
 
 /**
  * snd_fw_transaction - send a request and wait for its completion
@@ -20,6 +20,9 @@
  * @offset: the address in the target's address space
  * @buffer: input/output data
  * @length: length of @buffer
+ * @flags: use %FW_FIXED_GENERATION and add the generation value to attempt the
+ *         request only in that generation; use %FW_QUIET to suppress error
+ *         messages
  *
  * Submits an asynchronous request to the target device, and waits for the
  * response.  The node ID and the current generation are derived from @unit.
  * Returns zero on success, or a negative error code.
  */
 int snd_fw_transaction(struct fw_unit *unit, int tcode,
-                      u64 offset, void *buffer, size_t length)
+                      u64 offset, void *buffer, size_t length,
+                      unsigned int flags)
 {
        struct fw_device *device = fw_parent_device(unit);
        int generation, rcode, tries = 0;
 
+       generation = flags & FW_GENERATION_MASK;
        for (;;) {
-               generation = device->generation;
-               smp_rmb(); /* node_id vs. generation */
+               if (!(flags & FW_FIXED_GENERATION)) {
+                       generation = device->generation;
+                       smp_rmb(); /* node_id vs. generation */
+               }
                rcode = fw_run_transaction(device->card, tcode,
                                           device->node_id, generation,
                                           device->max_speed, offset,
@@ -43,9 +50,14 @@ int snd_fw_transaction(struct fw_unit *unit, int tcode,
                if (rcode == RCODE_COMPLETE)
                        return 0;
 
+               if (rcode == RCODE_GENERATION && (flags & FW_FIXED_GENERATION))
+                       return -EAGAIN;
+
                if (rcode_is_permanent_error(rcode) || ++tries >= 3) {
-                       dev_err(&unit->device, "transaction failed: %s\n",
-                               fw_rcode_string(rcode));
+                       if (!(flags & FW_QUIET))
+                               dev_err(&unit->device,
+                                       "transaction failed: %s\n",
+                                       fw_rcode_string(rcode));
                        return -EIO;
                }
 
index aef301476ea943bf9bbff8a9bfb8a28b6661a906..02cfabc9c3c4ba53d18e7b827600491fd9c2df84 100644 (file)
@@ -6,8 +6,13 @@
 
 struct fw_unit;
 
+#define FW_GENERATION_MASK     0x00ff
+#define FW_FIXED_GENERATION    0x0100
+#define FW_QUIET               0x0200
+
 int snd_fw_transaction(struct fw_unit *unit, int tcode,
-                      u64 offset, void *buffer, size_t length);
+                      u64 offset, void *buffer, size_t length,
+                      unsigned int flags);
 
 /* returns true if retrying the transaction would not make sense */
 static inline bool rcode_is_permanent_error(int rcode)
index 505fc812319958e12e804a2917c6d6cd3b4df88d..858023cf4298c0cbf6022e16824ab26f085f2b59 100644 (file)
@@ -369,7 +369,7 @@ static int scs_init_hss_address(struct scs *scs)
        data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) |
                           scs->hss_handler.offset);
        err = snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST,
-                                HSS1394_ADDRESS, &data, 8);
+                                HSS1394_ADDRESS, &data, 8, 0);
        if (err < 0)
                dev_err(&scs->unit->device, "HSS1394 communication failed\n");
 
@@ -455,12 +455,16 @@ err_card:
 static void scs_update(struct fw_unit *unit)
 {
        struct scs *scs = dev_get_drvdata(&unit->device);
+       int generation;
        __be64 data;
 
        data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) |
                           scs->hss_handler.offset);
+       generation = fw_parent_device(unit)->generation;
+       smp_rmb(); /* node_id vs. generation */
        snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST,
-                          HSS1394_ADDRESS, &data, 8);
+                          HSS1394_ADDRESS, &data, 8,
+                          FW_FIXED_GENERATION | generation);
 }
 
 static void scs_remove(struct fw_unit *unit)
index fe9e6e2f2c5b2a825ae24a432541d45de8f029fb..cc8bc3a51bc147ab7a13c0a38ec84134b55f9da3 100644 (file)
@@ -52,7 +52,6 @@ struct fwspk {
        struct mutex mutex;
        struct cmp_connection connection;
        struct amdtp_out_stream stream;
-       bool stream_running;
        bool mute;
        s16 volume[6];
        s16 volume_min;
@@ -188,10 +187,9 @@ static int fwspk_close(struct snd_pcm_substream *substream)
 
 static void fwspk_stop_stream(struct fwspk *fwspk)
 {
-       if (fwspk->stream_running) {
+       if (amdtp_out_stream_running(&fwspk->stream)) {
                amdtp_out_stream_stop(&fwspk->stream);
                cmp_connection_break(&fwspk->connection);
-               fwspk->stream_running = false;
        }
 }
 
@@ -246,8 +244,10 @@ static int fwspk_hw_params(struct snd_pcm_substream *substream,
        if (err < 0)
                goto error;
 
-       amdtp_out_stream_set_rate(&fwspk->stream, params_rate(hw_params));
-       amdtp_out_stream_set_pcm(&fwspk->stream, params_channels(hw_params));
+       amdtp_out_stream_set_parameters(&fwspk->stream,
+                                       params_rate(hw_params),
+                                       params_channels(hw_params),
+                                       0);
 
        amdtp_out_stream_set_pcm_format(&fwspk->stream,
                                        params_format(hw_params));
@@ -285,7 +285,7 @@ static int fwspk_prepare(struct snd_pcm_substream *substream)
        if (amdtp_out_streaming_error(&fwspk->stream))
                fwspk_stop_stream(fwspk);
 
-       if (!fwspk->stream_running) {
+       if (!amdtp_out_stream_running(&fwspk->stream)) {
                err = cmp_connection_establish(&fwspk->connection,
                        amdtp_out_stream_get_max_payload(&fwspk->stream));
                if (err < 0)
@@ -296,8 +296,6 @@ static int fwspk_prepare(struct snd_pcm_substream *substream)
                                        fwspk->connection.speed);
                if (err < 0)
                        goto err_connection;
-
-               fwspk->stream_running = true;
        }
 
        mutex_unlock(&fwspk->mutex);
@@ -647,7 +645,7 @@ static u32 fwspk_read_firmware_version(struct fw_unit *unit)
        int err;
 
        err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
-                                OXFORD_FIRMWARE_ID_ADDRESS, &data, 4);
+                                OXFORD_FIRMWARE_ID_ADDRESS, &data, 4, 0);
        return err >= 0 ? be32_to_cpu(data) : 0;
 }
 
index c0be085e4a200e4878097138b9294fe0d4a0855c..0e7254bde4c271cb9591724c2c8da0210c0d4426 100644 (file)
@@ -1544,7 +1544,7 @@ static int ess_has_rec_mixer (int submodel)
                return 1;
        default:
                return 0;
-       };
+       }
 };
 
 #ifdef FKS_LOGGING
index dc632cdc38706ec74c18978739e0819257e1d3a8..5f2acd35dcb9f4ccf26d6263e8fcba1f6a984683 100644 (file)
@@ -1913,6 +1913,7 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol,
        struct snd_card_asihpi *asihpi = snd_kcontrol_chip(kcontrol);
        */
        u32 h_control = kcontrol->private_value;
+       unsigned int idx;
        u16 band;
        u16 tuner_bands[HPI_TUNER_BAND_LAST];
        u32 num_bands = 0;
@@ -1920,7 +1921,10 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol,
        num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands,
                        HPI_TUNER_BAND_LAST);
 
-       band = tuner_bands[ucontrol->value.enumerated.item[0]];
+       idx = ucontrol->value.enumerated.item[0];
+       if (idx >= ARRAY_SIZE(tuner_bands))
+               idx = ARRAY_SIZE(tuner_bands) - 1;
+       band = tuner_bands[idx];
        hpi_handle_error(hpi_tuner_set_band(h_control, band));
 
        return 1;
@@ -2383,7 +2387,8 @@ static int snd_asihpi_clksrc_put(struct snd_kcontrol *kcontrol,
        struct snd_card_asihpi *asihpi =
                        (struct snd_card_asihpi *)(kcontrol->private_data);
        struct clk_cache *clkcache = &asihpi->cc;
-       int change, item;
+       unsigned int item;
+       int change;
        u32 h_control = kcontrol->private_value;
 
        change = 1;
index b46dc9b24dbd70d7c564c9a8853d8855f33a9ce7..9fb03b4ea925cb173e3e898950c9b4736c0ff787 100644 (file)
@@ -671,7 +671,7 @@ static int snd_vortex_new_pcm(vortex_t *chip, int idx, int nr)
                        return err;
                break;
 #endif
-       };
+       }
 
        if (VORTEX_PCM_TYPE(pcm) == VORTEX_PCM_SPDIF) {
                for (i = 0; i < ARRAY_SIZE(snd_vortex_mixer_spdif); i++) {
index 8bef47311e45025aeeb6552054c50dd520a8ad9d..922a84bba2ef4738006e02dcc1c3920525ce8ec6 100644 (file)
@@ -219,7 +219,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
                */
                hwwrite(vortex->mmio, WT_RUN(wt), val);
                return 0xc;
-               break;
        case 1:         /* param 0 */
                /*
                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
@@ -227,7 +226,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
                */
                hwwrite(vortex->mmio, WT_PARM(wt, 0), val);
                return 0xc;
-               break;
        case 2:         /* param 1 */
                /*
                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
@@ -235,7 +233,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
                */
                hwwrite(vortex->mmio, WT_PARM(wt, 1), val);
                return 0xc;
-               break;
        case 3:         /* param 2 */
                /*
                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
@@ -243,7 +240,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
                */
                hwwrite(vortex->mmio, WT_PARM(wt, 2), val);
                return 0xc;
-               break;
        case 4:         /* param 3 */
                /*
                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
@@ -251,7 +247,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
                */
                hwwrite(vortex->mmio, WT_PARM(wt, 3), val);
                return 0xc;
-               break;
        case 6:         /* mute */
                /*
                printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
@@ -259,20 +254,17 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
                */
                hwwrite(vortex->mmio, WT_MUTE(wt), val);
                return 0xc;
-               break;
        case 0xb:
-               {               /* delay */
-                       /*
-                       printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
-                              WT_DELAY(wt,0), (int)val);
-                       */
-                       hwwrite(vortex->mmio, WT_DELAY(wt, 3), val);
-                       hwwrite(vortex->mmio, WT_DELAY(wt, 2), val);
-                       hwwrite(vortex->mmio, WT_DELAY(wt, 1), val);
-                       hwwrite(vortex->mmio, WT_DELAY(wt, 0), val);
-                       return 0xc;
-               }
-               break;
+                       /* delay */
+               /*
+               printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
+                      WT_DELAY(wt,0), (int)val);
+               */
+               hwwrite(vortex->mmio, WT_DELAY(wt, 3), val);
+               hwwrite(vortex->mmio, WT_DELAY(wt, 2), val);
+               hwwrite(vortex->mmio, WT_DELAY(wt, 1), val);
+               hwwrite(vortex->mmio, WT_DELAY(wt, 0), val);
+               return 0xc;
                /* Global WT block parameters */
        case 5:         /* sramp */
                ecx = WT_SRAMP(wt);
@@ -291,7 +283,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
                break;
        default:
                return 0;
-               break;
        }
        /*
        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val);
index c8e1216115936015a73e67df84e2c83ecc0d1975..1aef7128f7caa97e0daacaeb312ee60d1ec9225f 100644 (file)
@@ -715,14 +715,14 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97)
        const struct snd_azf3328 *chip = ac97->private_data;
        unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97);
        unsigned short reg_val = 0;
-       bool unsupported = 0;
+       bool unsupported = false;
 
        snd_azf3328_dbgmixer(
                "snd_azf3328_mixer_ac97_read reg_ac97 %u\n",
                        reg_ac97
        );
        if (reg_azf & AZF_AC97_REG_UNSUPPORTED)
-               unsupported = 1;
+               unsupported = true;
        else {
                if (reg_azf & AZF_AC97_REG_REAL_IO_READ)
                        reg_val = snd_azf3328_mixer_inw(chip,
@@ -759,7 +759,7 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97)
                                reg_val = azf_emulated_ac97_vendor_id & 0xffff;
                                break;
                        default:
-                               unsupported = 1;
+                               unsupported = true;
                                break;
                        }
                }
@@ -776,14 +776,14 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97,
 {
        const struct snd_azf3328 *chip = ac97->private_data;
        unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97);
-       bool unsupported = 0;
+       bool unsupported = false;
 
        snd_azf3328_dbgmixer(
                "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n",
                        reg_ac97, val
        );
        if (reg_azf & AZF_AC97_REG_UNSUPPORTED)
-               unsupported = 1;
+               unsupported = true;
        else {
                if (reg_azf & AZF_AC97_REG_REAL_IO_WRITE)
                        snd_azf3328_mixer_outw(
@@ -808,7 +808,7 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97,
                                 */
                                break;
                        default:
-                               unsupported = 1;
+                               unsupported = true;
                                break;
                        }
                }
@@ -1559,7 +1559,7 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        struct snd_azf3328_codec_data *codec = runtime->private_data;
        int result = 0;
        u16 flags1;
-       bool previously_muted = 0;
+       bool previously_muted = false;
        bool is_main_mixer_playback_codec = (AZF_CODEC_PLAYBACK == codec->type);
 
        snd_azf3328_dbgcalls("snd_azf3328_pcm_trigger cmd %d\n", cmd);
index 0c00eb4088efca6639bf35c554aefa73f9e926e5..84f86bf63b8fc31dc27700013608a65a7af970bb 100644 (file)
@@ -33,7 +33,7 @@ struct daio_rsc_idx {
        unsigned short right;
 };
 
-struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = {
+static struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = {
        [LINEO1] = {.left = 0x00, .right = 0x01},
        [LINEO2] = {.left = 0x18, .right = 0x19},
        [LINEO3] = {.left = 0x08, .right = 0x09},
@@ -44,7 +44,7 @@ struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = {
        [SPDIFI1] = {.left = 0x95, .right = 0x9d},
 };
 
-struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = {
+static struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = {
        [LINEO1] = {.left = 0x40, .right = 0x41},
        [LINEO2] = {.left = 0x60, .right = 0x61},
        [LINEO3] = {.left = 0x50, .right = 0x51},
index 0275209ca82e33bb4fd0c69569c31e08993a87d2..1f9c7c4bbcd8b0f3db5fb8552a24fba5dd9467f8 100644 (file)
@@ -1182,15 +1182,20 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
        u32 *gpr_map;
        mm_segment_t seg;
 
-       if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL ||
-           (icode->gpr_map = (u_int32_t __user *)
-            kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
-                    GFP_KERNEL)) == NULL ||
-           (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
-                               sizeof(*controls), GFP_KERNEL)) == NULL) {
-               err = -ENOMEM;
-               goto __err;
-       }
+       err = -ENOMEM;
+       icode = kzalloc(sizeof(*icode), GFP_KERNEL);
+       if (!icode)
+               return err;
+
+       icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024,
+                                                     sizeof(u_int32_t), GFP_KERNEL);
+       if (!icode->gpr_map)
+               goto __err_gpr;
+       controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
+                          sizeof(*controls), GFP_KERNEL);
+       if (!controls)
+               goto __err_ctrls;
+
        gpr_map = (u32 __force *)icode->gpr_map;
 
        icode->tram_data_map = icode->gpr_map + 512;
@@ -1741,12 +1746,12 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
        emu->support_tlv = 0; /* clear again */
        snd_leave_user(seg);
 
- __err:
+__err:
        kfree(controls);
-       if (icode != NULL) {
-               kfree((void __force *)icode->gpr_map);
-               kfree(icode);
-       }
+__err_ctrls:
+       kfree((void __force *)icode->gpr_map);
+__err_gpr:
+       kfree(icode);
        return err;
 }
 
@@ -1813,18 +1818,26 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
        u32 *gpr_map;
        mm_segment_t seg;
 
-       if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
-               return -ENOMEM;
-       if ((icode->gpr_map = (u_int32_t __user *)
-            kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
-                    GFP_KERNEL)) == NULL ||
-            (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
-                               sizeof(struct snd_emu10k1_fx8010_control_gpr),
-                               GFP_KERNEL)) == NULL ||
-           (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
-               err = -ENOMEM;
-               goto __err;
-       }
+       err = -ENOMEM;
+       icode = kzalloc(sizeof(*icode), GFP_KERNEL);
+       if (!icode)
+               return err;
+
+       icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512,
+                                                     sizeof(u_int32_t), GFP_KERNEL);
+       if (!icode->gpr_map)
+               goto __err_gpr;
+
+       controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
+                          sizeof(struct snd_emu10k1_fx8010_control_gpr),
+                          GFP_KERNEL);
+       if (!controls)
+               goto __err_ctrls;
+
+       ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL);
+       if (!ipcm)
+               goto __err_ipcm;
+
        gpr_map = (u32 __force *)icode->gpr_map;
 
        icode->tram_data_map = icode->gpr_map + 256;
@@ -2363,13 +2376,14 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
        snd_leave_user(seg);
        if (err >= 0)
                err = snd_emu10k1_ipcm_poke(emu, ipcm);
-      __err:
+__err:
        kfree(ipcm);
+__err_ipcm:
        kfree(controls);
-       if (icode != NULL) {
-               kfree((void __force *)icode->gpr_map);
-               kfree(icode);
-       }
+__err_ctrls:
+       kfree((void __force *)icode->gpr_map);
+__err_gpr:
+       kfree(icode);
        return err;
 }
 
index 63c99090a4ecc94ff617d1de8252ccf3ccccd609..20d065a172269dc9b5f8d3bd5997620d7c63b85d 100644 (file)
@@ -151,10 +151,8 @@ static int snd_hda_do_attach(struct hda_beep *beep)
        int err;
 
        input_dev = input_allocate_device();
-       if (!input_dev) {
-               printk(KERN_INFO "hda_beep: unable to allocate input device\n");
+       if (!input_dev)
                return -ENOMEM;
-       }
 
        /* setup digital beep device */
        input_dev->name = "HDA Digital PCBeep";
index 748c6a941963cbcb6108bc8aac90843cca7ee72f..0faab3b4dabb7e182033764f053064f890cb636c 100644 (file)
@@ -565,7 +565,7 @@ int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid,
                range_val = !!(parm & (1 << (shift-1))); /* ranges */
                val = parm & mask;
                if (val == 0 && null_count++) {  /* no second chance */
-                       snd_printk(KERN_WARNING "hda_codec: "
+                       snd_printdd("hda_codec: "
                                   "invalid CONNECT_LIST verb %x[%i]:%x\n",
                                    nid, i, parm);
                        return 0;
@@ -5395,11 +5395,6 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
                        snd_hda_codec_setup_stream(codec,
                                                   mout->hp_out_nid[i],
                                                   stream_tag, 0, format);
-       for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
-               if (!mout->no_share_stream && mout->extra_out_nid[i])
-                       snd_hda_codec_setup_stream(codec,
-                                                  mout->extra_out_nid[i],
-                                                  stream_tag, 0, format);
 
        /* surrounds */
        for (i = 1; i < mout->num_dacs; i++) {
@@ -5410,6 +5405,20 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
                        snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
                                                   0, format);
        }
+
+       /* extra surrounds */
+       for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) {
+               int ch = 0;
+               if (!mout->extra_out_nid[i])
+                       break;
+               if (chs >= (i + 1) * 2)
+                       ch = i * 2;
+               else if (!mout->no_share_stream)
+                       break;
+               snd_hda_codec_setup_stream(codec, mout->extra_out_nid[i],
+                                          stream_tag, ch, format);
+       }
+
        return 0;
 }
 EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare);
index 7aa9870040c102df5b02aa0a94778c8e14c36024..77db69480c195cde15ee64dd13bb18b2f81aa2de 100644 (file)
@@ -698,6 +698,7 @@ struct hda_bus {
        unsigned int in_reset:1;        /* during reset operation */
        unsigned int power_keep_link_on:1; /* don't power off HDA link */
        unsigned int no_response_fallback:1; /* don't fallback at RIRB error */
+       unsigned int avoid_link_reset:1; /* don't reset link at runtime PM */
 
        int primary_dig_out_type;       /* primary digital out PCM type */
 };
index d0d7ac1e99d24cc606b441e6ec23470a75800dcd..32d3e3855a6eb99f298a97c3168e604a74ceae77 100644 (file)
@@ -2,6 +2,7 @@
  * Generic routines and proc interface for ELD(EDID Like Data) information
  *
  * Copyright(c) 2008 Intel Corporation.
+ * Copyright (c) 2013 Anssi Hannula <anssi.hannula@iki.fi>
  *
  * Authors:
  *             Wu Fengguang <wfg@linux.intel.com>
@@ -478,10 +479,9 @@ static void hdmi_print_sad_info(int i, struct cea_sad *a,
                snd_iprintf(buffer, "sad%d_profile\t\t%d\n", i, a->profile);
 }
 
-static void hdmi_print_eld_info(struct snd_info_entry *entry,
-                               struct snd_info_buffer *buffer)
+void snd_hdmi_print_eld_info(struct hdmi_eld *eld,
+                            struct snd_info_buffer *buffer)
 {
-       struct hdmi_eld *eld = entry->private_data;
        struct parsed_hdmi_eld *e = &eld->info;
        char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
        int i;
@@ -500,13 +500,10 @@ static void hdmi_print_eld_info(struct snd_info_entry *entry,
                [4 ... 7] = "reserved"
        };
 
-       mutex_lock(&eld->lock);
        snd_iprintf(buffer, "monitor_present\t\t%d\n", eld->monitor_present);
        snd_iprintf(buffer, "eld_valid\t\t%d\n", eld->eld_valid);
-       if (!eld->eld_valid) {
-               mutex_unlock(&eld->lock);
+       if (!eld->eld_valid)
                return;
-       }
        snd_iprintf(buffer, "monitor_name\t\t%s\n", e->monitor_name);
        snd_iprintf(buffer, "connection_type\t\t%s\n",
                                eld_connection_type_names[e->conn_type]);
@@ -528,13 +525,11 @@ static void hdmi_print_eld_info(struct snd_info_entry *entry,
 
        for (i = 0; i < e->sad_count; i++)
                hdmi_print_sad_info(i, e->sad + i, buffer);
-       mutex_unlock(&eld->lock);
 }
 
-static void hdmi_write_eld_info(struct snd_info_entry *entry,
-                               struct snd_info_buffer *buffer)
+void snd_hdmi_write_eld_info(struct hdmi_eld *eld,
+                            struct snd_info_buffer *buffer)
 {
-       struct hdmi_eld *eld = entry->private_data;
        struct parsed_hdmi_eld *e = &eld->info;
        char line[64];
        char name[64];
@@ -542,7 +537,6 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry,
        long long val;
        unsigned int n;
 
-       mutex_lock(&eld->lock);
        while (!snd_info_get_line(buffer, line, sizeof(line))) {
                if (sscanf(line, "%s %llx", name, &val) != 2)
                        continue;
@@ -594,38 +588,7 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry,
                                e->sad_count = n + 1;
                }
        }
-       mutex_unlock(&eld->lock);
-}
-
-
-int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld,
-                        int index)
-{
-       char name[32];
-       struct snd_info_entry *entry;
-       int err;
-
-       snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index);
-       err = snd_card_proc_new(codec->bus->card, name, &entry);
-       if (err < 0)
-               return err;
-
-       snd_info_set_text_ops(entry, eld, hdmi_print_eld_info);
-       entry->c.text.write = hdmi_write_eld_info;
-       entry->mode |= S_IWUSR;
-       eld->proc_entry = entry;
-
-       return 0;
-}
-
-void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
-{
-       if (!codec->bus->shutdown && eld->proc_entry) {
-               snd_device_free(codec->bus->card, eld->proc_entry);
-               eld->proc_entry = NULL;
-       }
 }
-
 #endif /* CONFIG_PROC_FS */
 
 /* update PCM info based on ELD */
@@ -671,3 +634,153 @@ void snd_hdmi_eld_update_pcm_info(struct parsed_hdmi_eld *e,
        hinfo->maxbps = min(hinfo->maxbps, maxbps);
        hinfo->channels_max = min(hinfo->channels_max, channels_max);
 }
+
+
+/* ATI/AMD specific stuff (ELD emulation) */
+
+#define ATI_VERB_SET_AUDIO_DESCRIPTOR  0x776
+#define ATI_VERB_SET_SINK_INFO_INDEX   0x780
+#define ATI_VERB_GET_SPEAKER_ALLOCATION        0xf70
+#define ATI_VERB_GET_AUDIO_DESCRIPTOR  0xf76
+#define ATI_VERB_GET_AUDIO_VIDEO_DELAY 0xf7b
+#define ATI_VERB_GET_SINK_INFO_INDEX   0xf80
+#define ATI_VERB_GET_SINK_INFO_DATA    0xf81
+
+#define ATI_SPKALLOC_SPKALLOC          0x007f
+#define ATI_SPKALLOC_TYPE_HDMI         0x0100
+#define ATI_SPKALLOC_TYPE_DISPLAYPORT  0x0200
+
+/* first three bytes are just standard SAD */
+#define ATI_AUDIODESC_CHANNELS         0x00000007
+#define ATI_AUDIODESC_RATES            0x0000ff00
+#define ATI_AUDIODESC_LPCM_STEREO_RATES        0xff000000
+
+/* in standard HDMI VSDB format */
+#define ATI_DELAY_VIDEO_LATENCY                0x000000ff
+#define ATI_DELAY_AUDIO_LATENCY                0x0000ff00
+
+enum ati_sink_info_idx {
+       ATI_INFO_IDX_MANUFACTURER_ID    = 0,
+       ATI_INFO_IDX_PRODUCT_ID         = 1,
+       ATI_INFO_IDX_SINK_DESC_LEN      = 2,
+       ATI_INFO_IDX_PORT_ID_LOW        = 3,
+       ATI_INFO_IDX_PORT_ID_HIGH       = 4,
+       ATI_INFO_IDX_SINK_DESC_FIRST    = 5,
+       ATI_INFO_IDX_SINK_DESC_LAST     = 22, /* max len 18 bytes */
+};
+
+int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
+                        unsigned char *buf, int *eld_size, bool rev3_or_later)
+{
+       int spkalloc, ati_sad, aud_synch;
+       int sink_desc_len = 0;
+       int pos, i;
+
+       /* ATI/AMD does not have ELD, emulate it */
+
+       spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0);
+
+       if (!spkalloc) {
+               snd_printd(KERN_INFO "HDMI ATI/AMD: no speaker allocation for ELD\n");
+               return -EINVAL;
+       }
+
+       memset(buf, 0, ELD_FIXED_BYTES + ELD_MAX_MNL + ELD_MAX_SAD * 3);
+
+       /* version */
+       buf[0] = ELD_VER_CEA_861D << 3;
+
+       /* speaker allocation from EDID */
+       buf[7] = spkalloc & ATI_SPKALLOC_SPKALLOC;
+
+       /* is DisplayPort? */
+       if (spkalloc & ATI_SPKALLOC_TYPE_DISPLAYPORT)
+               buf[5] |= 0x04;
+
+       pos = ELD_FIXED_BYTES;
+
+       if (rev3_or_later) {
+               int sink_info;
+
+               snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PORT_ID_LOW);
+               sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0);
+               put_unaligned_le32(sink_info, buf + 8);
+
+               snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PORT_ID_HIGH);
+               sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0);
+               put_unaligned_le32(sink_info, buf + 12);
+
+               snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_MANUFACTURER_ID);
+               sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0);
+               put_unaligned_le16(sink_info, buf + 16);
+
+               snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PRODUCT_ID);
+               sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0);
+               put_unaligned_le16(sink_info, buf + 18);
+
+               snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_SINK_DESC_LEN);
+               sink_desc_len = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0);
+
+               if (sink_desc_len > ELD_MAX_MNL) {
+                       snd_printd(KERN_INFO "HDMI ATI/AMD: Truncating HDMI sink description with length %d\n",
+                                  sink_desc_len);
+                       sink_desc_len = ELD_MAX_MNL;
+               }
+
+               buf[4] |= sink_desc_len;
+
+               for (i = 0; i < sink_desc_len; i++) {
+                       snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_SINK_DESC_FIRST + i);
+                       buf[pos++] = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0);
+               }
+       }
+
+       for (i = AUDIO_CODING_TYPE_LPCM; i <= AUDIO_CODING_TYPE_WMAPRO; i++) {
+               if (i == AUDIO_CODING_TYPE_SACD || i == AUDIO_CODING_TYPE_DST)
+                       continue; /* not handled by ATI/AMD */
+
+               snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_AUDIO_DESCRIPTOR, i << 3);
+               ati_sad = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_DESCRIPTOR, 0);
+
+               if (ati_sad & ATI_AUDIODESC_RATES) {
+                       /* format is supported, copy SAD as-is */
+                       buf[pos++] = (ati_sad & 0x0000ff) >> 0;
+                       buf[pos++] = (ati_sad & 0x00ff00) >> 8;
+                       buf[pos++] = (ati_sad & 0xff0000) >> 16;
+               }
+
+               if (i == AUDIO_CODING_TYPE_LPCM
+                   && (ati_sad & ATI_AUDIODESC_LPCM_STEREO_RATES)
+                   && (ati_sad & ATI_AUDIODESC_LPCM_STEREO_RATES) >> 16 != (ati_sad & ATI_AUDIODESC_RATES)) {
+                       /* for PCM there is a separate stereo rate mask */
+                       buf[pos++] = ((ati_sad & 0x000000ff) & ~ATI_AUDIODESC_CHANNELS) | 0x1;
+                       /* rates from the extra byte */
+                       buf[pos++] = (ati_sad & 0xff000000) >> 24;
+                       buf[pos++] = (ati_sad & 0x00ff0000) >> 16;
+               }
+       }
+
+       if (pos == ELD_FIXED_BYTES + sink_desc_len) {
+               snd_printd(KERN_INFO "HDMI ATI/AMD: no audio descriptors for ELD\n");
+               return -EINVAL;
+       }
+
+       aud_synch = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_VIDEO_DELAY, 0);
+       if ((aud_synch & ATI_DELAY_VIDEO_LATENCY) && (aud_synch & ATI_DELAY_AUDIO_LATENCY)) {
+               int video_latency = (aud_synch & ATI_DELAY_VIDEO_LATENCY) - 1;
+               int audio_latency = ((aud_synch & ATI_DELAY_AUDIO_LATENCY) >> 8) - 1;
+
+               if (video_latency > audio_latency)
+                       buf[6] = min(video_latency - audio_latency, 0xfa);
+       }
+
+       /* Baseline length */
+       buf[2] = pos - 4;
+
+       /* SAD count */
+       buf[5] |= ((pos - ELD_FIXED_BYTES - sink_desc_len) / 3) << 4;
+
+       *eld_size = pos;
+
+       return 0;
+}
index 6e61a019aa5e4040e9f29bc58fdc35e799207f24..a0a06f79daa3b85185f15bcd98843ffa3fb83e41 100644 (file)
@@ -2986,7 +2986,8 @@ static int azx_runtime_suspend(struct device *dev)
                  STATESTS_INT_MASK);
 
        azx_stop_chip(chip);
-       azx_enter_link_reset(chip);
+       if (!chip->bus->avoid_link_reset)
+               azx_enter_link_reset(chip);
        azx_clear_irq_pending(chip);
        if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
                hda_display_power(false);
index 2e7493ef8ee0643b1ee51b759198c233d23af6a5..d398b648bb5d1478d63e8d430d333eedda45beb3 100644 (file)
@@ -428,6 +428,7 @@ enum {
        HDA_FIXUP_ACT_PROBE,
        HDA_FIXUP_ACT_INIT,
        HDA_FIXUP_ACT_BUILD,
+       HDA_FIXUP_ACT_FREE,
 };
 
 int snd_hda_add_verbs(struct hda_codec *codec, const struct hda_verb *list);
@@ -751,10 +752,6 @@ struct hdmi_eld {
        int     eld_size;
        char    eld_buffer[ELD_MAX_SIZE];
        struct parsed_hdmi_eld info;
-       struct mutex lock;
-#ifdef CONFIG_PROC_FS
-       struct snd_info_entry *proc_entry;
-#endif
 };
 
 int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
@@ -766,21 +763,15 @@ void snd_hdmi_show_eld(struct parsed_hdmi_eld *e);
 void snd_hdmi_eld_update_pcm_info(struct parsed_hdmi_eld *e,
                              struct hda_pcm_stream *hinfo);
 
+int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
+                        unsigned char *buf, int *eld_size,
+                        bool rev3_or_later);
+
 #ifdef CONFIG_PROC_FS
-int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld,
-                        int index);
-void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld);
-#else
-static inline int snd_hda_eld_proc_new(struct hda_codec *codec,
-                                      struct hdmi_eld *eld,
-                                      int index)
-{
-       return 0;
-}
-static inline void snd_hda_eld_proc_free(struct hda_codec *codec,
-                                        struct hdmi_eld *eld)
-{
-}
+void snd_hdmi_print_eld_info(struct hdmi_eld *eld,
+                            struct snd_info_buffer *buffer);
+void snd_hdmi_write_eld_info(struct hdmi_eld *eld,
+                            struct snd_info_buffer *buffer);
 #endif
 
 #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
index 6e9876f27d959a64e14443ceab5efaed9f11d44b..54d14793725a7dd93623083d29f72f41a5ddc4bd 100644 (file)
@@ -759,7 +759,7 @@ struct ca0132_spec {
 /*
  * CA0132 codec access
  */
-unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid,
+static unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid,
                unsigned int verb, unsigned int parm, unsigned int *res)
 {
        unsigned int response;
index ec68eaea0336a008c78fb05c03a4d6c0e3f99c2a..993b25c17711dbb6b81b81c7f0129a5de2393eec 100644 (file)
@@ -3208,11 +3208,17 @@ static int cx_auto_init(struct hda_codec *codec)
        return 0;
 }
 
+static void cx_auto_free(struct hda_codec *codec)
+{
+       snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
+       snd_hda_gen_free(codec);
+}
+
 static const struct hda_codec_ops cx_auto_patch_ops = {
        .build_controls = cx_auto_build_controls,
        .build_pcms = snd_hda_gen_build_pcms,
        .init = cx_auto_init,
-       .free = snd_hda_gen_free,
+       .free = cx_auto_free,
        .unsol_event = snd_hda_jack_unsol_event,
 #ifdef CONFIG_PM
        .check_power_status = snd_hda_gen_check_power_status,
@@ -3232,8 +3238,84 @@ enum {
        CXT_FIXUP_HEADPHONE_MIC_PIN,
        CXT_FIXUP_HEADPHONE_MIC,
        CXT_FIXUP_GPIO1,
+       CXT_FIXUP_THINKPAD_ACPI,
 };
 
+#if IS_ENABLED(CONFIG_THINKPAD_ACPI)
+
+#include <linux/thinkpad_acpi.h>
+
+static int (*led_set_func)(int, bool);
+
+static void update_tpacpi_mute_led(void *private_data, int enabled)
+{
+       struct hda_codec *codec = private_data;
+       struct conexant_spec *spec = codec->spec;
+
+       if (spec->dynamic_eapd)
+               cx_auto_vmaster_hook(private_data, enabled);
+
+       if (led_set_func)
+               led_set_func(TPACPI_LED_MUTE, !enabled);
+}
+
+static void update_tpacpi_micmute_led(struct hda_codec *codec,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       if (!ucontrol || !led_set_func)
+               return;
+       if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) {
+               /* TODO: How do I verify if it's a mono or stereo here? */
+               bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1];
+               led_set_func(TPACPI_LED_MICMUTE, !val);
+       }
+}
+
+static void cxt_fixup_thinkpad_acpi(struct hda_codec *codec,
+                                 const struct hda_fixup *fix, int action)
+{
+       struct conexant_spec *spec = codec->spec;
+
+       bool removefunc = false;
+
+       if (action == HDA_FIXUP_ACT_PROBE) {
+               if (!led_set_func)
+                       led_set_func = symbol_request(tpacpi_led_set);
+               if (!led_set_func) {
+                       snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n");
+                       return;
+               }
+
+               removefunc = true;
+               if (led_set_func(TPACPI_LED_MUTE, false) >= 0) {
+                       spec->gen.vmaster_mute.hook = update_tpacpi_mute_led;
+                       removefunc = false;
+               }
+               if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
+                       if (spec->gen.num_adc_nids > 1)
+                               snd_printdd("Skipping micmute LED control due to several ADCs");
+                       else {
+                               spec->gen.cap_sync_hook = update_tpacpi_micmute_led;
+                               removefunc = false;
+                       }
+               }
+       }
+
+       if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) {
+               symbol_put(tpacpi_led_set);
+               led_set_func = NULL;
+       }
+}
+
+#else
+
+static void cxt_fixup_thinkpad_acpi(struct hda_codec *codec,
+                                 const struct hda_fixup *fix, int action)
+{
+}
+
+#endif
+
 static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
                                  const struct hda_fixup *fix, int action)
 {
@@ -3344,6 +3426,8 @@ static const struct hda_fixup cxt_fixups[] = {
        [CXT_PINCFG_LENOVO_TP410] = {
                .type = HDA_FIXUP_PINS,
                .v.pins = cxt_pincfg_lenovo_tp410,
+               .chained = true,
+               .chain_id = CXT_FIXUP_THINKPAD_ACPI,
        },
        [CXT_PINCFG_LEMOTE_A1004] = {
                .type = HDA_FIXUP_PINS,
@@ -3385,6 +3469,10 @@ static const struct hda_fixup cxt_fixups[] = {
                        { }
                },
        },
+       [CXT_FIXUP_THINKPAD_ACPI] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = cxt_fixup_thinkpad_acpi,
+       },
 };
 
 static const struct snd_pci_quirk cxt5051_fixups[] = {
@@ -3507,7 +3595,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
        return 0;
 
  error:
-       snd_hda_gen_free(codec);
+       cx_auto_free(codec);
        return err;
 }
 
index 50173d412ac5c0d5fb7095b3e3004e2c63c319a0..772827b9fb204c2a8488e7c00a5236b5ab54c7ce 100644 (file)
@@ -6,6 +6,7 @@
  *  Copyright (c) 2006 ATI Technologies Inc.
  *  Copyright (c) 2008 NVIDIA Corp.  All rights reserved.
  *  Copyright (c) 2008 Wei Ni <wni@nvidia.com>
+ *  Copyright (c) 2013 Anssi Hannula <anssi.hannula@iki.fi>
  *
  *  Authors:
  *                     Wu Fengguang <wfg@linux.intel.com>
@@ -63,9 +64,11 @@ struct hdmi_spec_per_pin {
        hda_nid_t pin_nid;
        int num_mux_nids;
        hda_nid_t mux_nids[HDA_MAX_CONNECTIONS];
+       hda_nid_t cvt_nid;
 
        struct hda_codec *codec;
        struct hdmi_eld sink_eld;
+       struct mutex lock;
        struct delayed_work work;
        struct snd_kcontrol *eld_ctl;
        int repoll_count;
@@ -75,6 +78,42 @@ struct hdmi_spec_per_pin {
        bool chmap_set;         /* channel-map override by ALSA API? */
        unsigned char chmap[8]; /* ALSA API channel-map */
        char pcm_name[8];       /* filled in build_pcm callbacks */
+#ifdef CONFIG_PROC_FS
+       struct snd_info_entry *proc_entry;
+#endif
+};
+
+struct cea_channel_speaker_allocation;
+
+/* operations used by generic code that can be overridden by patches */
+struct hdmi_ops {
+       int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
+                          unsigned char *buf, int *eld_size);
+
+       /* get and set channel assigned to each HDMI ASP (audio sample packet) slot */
+       int (*pin_get_slot_channel)(struct hda_codec *codec, hda_nid_t pin_nid,
+                                   int asp_slot);
+       int (*pin_set_slot_channel)(struct hda_codec *codec, hda_nid_t pin_nid,
+                                   int asp_slot, int channel);
+
+       void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
+                                   int ca, int active_channels, int conn_type);
+
+       /* enable/disable HBR (HD passthrough) */
+       int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid, bool hbr);
+
+       int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
+                           hda_nid_t pin_nid, u32 stream_tag, int format);
+
+       /* Helpers for producing the channel map TLVs. These can be overridden
+        * for devices that have non-standard mapping requirements. */
+       int (*chmap_cea_alloc_validate_get_type)(struct cea_channel_speaker_allocation *cap,
+                                                int channels);
+       void (*cea_alloc_to_tlv_chmap)(struct cea_channel_speaker_allocation *cap,
+                                      unsigned int *chmap, int channels);
+
+       /* check that the user-given chmap is supported */
+       int (*chmap_validate)(int ca, int channels, unsigned char *chmap);
 };
 
 struct hdmi_spec {
@@ -88,8 +127,9 @@ struct hdmi_spec {
        unsigned int channels_max; /* max over all cvts */
 
        struct hdmi_eld temp_eld;
+       struct hdmi_ops ops;
        /*
-        * Non-generic ATI/NVIDIA specific
+        * Non-generic VIA/NVIDIA specific
         */
        struct hda_multi_out multiout;
        struct hda_pcm_stream pcm_playback;
@@ -348,17 +388,19 @@ static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol,
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct hdmi_spec *spec = codec->spec;
+       struct hdmi_spec_per_pin *per_pin;
        struct hdmi_eld *eld;
        int pin_idx;
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
 
        pin_idx = kcontrol->private_value;
-       eld = &get_pin(spec, pin_idx)->sink_eld;
+       per_pin = get_pin(spec, pin_idx);
+       eld = &per_pin->sink_eld;
 
-       mutex_lock(&eld->lock);
+       mutex_lock(&per_pin->lock);
        uinfo->count = eld->eld_valid ? eld->eld_size : 0;
-       mutex_unlock(&eld->lock);
+       mutex_unlock(&per_pin->lock);
 
        return 0;
 }
@@ -368,15 +410,17 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct hdmi_spec *spec = codec->spec;
+       struct hdmi_spec_per_pin *per_pin;
        struct hdmi_eld *eld;
        int pin_idx;
 
        pin_idx = kcontrol->private_value;
-       eld = &get_pin(spec, pin_idx)->sink_eld;
+       per_pin = get_pin(spec, pin_idx);
+       eld = &per_pin->sink_eld;
 
-       mutex_lock(&eld->lock);
+       mutex_lock(&per_pin->lock);
        if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) {
-               mutex_unlock(&eld->lock);
+               mutex_unlock(&per_pin->lock);
                snd_BUG();
                return -EINVAL;
        }
@@ -386,7 +430,7 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
        if (eld->eld_valid)
                memcpy(ucontrol->value.bytes.data, eld->eld_buffer,
                       eld->eld_size);
-       mutex_unlock(&eld->lock);
+       mutex_unlock(&per_pin->lock);
 
        return 0;
 }
@@ -477,6 +521,68 @@ static void hdmi_set_channel_count(struct hda_codec *codec,
                                    AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
 }
 
+/*
+ * ELD proc files
+ */
+
+#ifdef CONFIG_PROC_FS
+static void print_eld_info(struct snd_info_entry *entry,
+                          struct snd_info_buffer *buffer)
+{
+       struct hdmi_spec_per_pin *per_pin = entry->private_data;
+
+       mutex_lock(&per_pin->lock);
+       snd_hdmi_print_eld_info(&per_pin->sink_eld, buffer);
+       mutex_unlock(&per_pin->lock);
+}
+
+static void write_eld_info(struct snd_info_entry *entry,
+                          struct snd_info_buffer *buffer)
+{
+       struct hdmi_spec_per_pin *per_pin = entry->private_data;
+
+       mutex_lock(&per_pin->lock);
+       snd_hdmi_write_eld_info(&per_pin->sink_eld, buffer);
+       mutex_unlock(&per_pin->lock);
+}
+
+static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index)
+{
+       char name[32];
+       struct hda_codec *codec = per_pin->codec;
+       struct snd_info_entry *entry;
+       int err;
+
+       snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index);
+       err = snd_card_proc_new(codec->bus->card, name, &entry);
+       if (err < 0)
+               return err;
+
+       snd_info_set_text_ops(entry, per_pin, print_eld_info);
+       entry->c.text.write = write_eld_info;
+       entry->mode |= S_IWUSR;
+       per_pin->proc_entry = entry;
+
+       return 0;
+}
+
+static void eld_proc_free(struct hdmi_spec_per_pin *per_pin)
+{
+       if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) {
+               snd_device_free(per_pin->codec->bus->card, per_pin->proc_entry);
+               per_pin->proc_entry = NULL;
+       }
+}
+#else
+static inline int eld_proc_new(struct hdmi_spec_per_pin *per_pin,
+                              int index)
+{
+       return 0;
+}
+static inline void eld_proc_free(struct hdmi_spec_per_pin *per_pin)
+{
+}
+#endif
 
 /*
  * Channel mapping routines
@@ -577,74 +683,91 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec,
                                       hda_nid_t pin_nid)
 {
 #ifdef CONFIG_SND_DEBUG_VERBOSE
+       struct hdmi_spec *spec = codec->spec;
        int i;
-       int slot;
+       int channel;
 
        for (i = 0; i < 8; i++) {
-               slot = snd_hda_codec_read(codec, pin_nid, 0,
-                                               AC_VERB_GET_HDMI_CHAN_SLOT, i);
+               channel = spec->ops.pin_get_slot_channel(codec, pin_nid, i);
                printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n",
-                                               slot >> 4, slot & 0xf);
+                                               channel, i);
        }
 #endif
 }
 
-
 static void hdmi_std_setup_channel_mapping(struct hda_codec *codec,
                                       hda_nid_t pin_nid,
                                       bool non_pcm,
                                       int ca)
 {
+       struct hdmi_spec *spec = codec->spec;
+       struct cea_channel_speaker_allocation *ch_alloc;
        int i;
        int err;
        int order;
        int non_pcm_mapping[8];
 
        order = get_channel_allocation_order(ca);
+       ch_alloc = &channel_allocations[order];
 
        if (hdmi_channel_mapping[ca][1] == 0) {
-               for (i = 0; i < channel_allocations[order].channels; i++)
-                       hdmi_channel_mapping[ca][i] = i | (i << 4);
-               for (; i < 8; i++)
-                       hdmi_channel_mapping[ca][i] = 0xf | (i << 4);
+               int hdmi_slot = 0;
+               /* fill actual channel mappings in ALSA channel (i) order */
+               for (i = 0; i < ch_alloc->channels; i++) {
+                       while (!ch_alloc->speakers[7 - hdmi_slot] && !WARN_ON(hdmi_slot >= 8))
+                               hdmi_slot++; /* skip zero slots */
+
+                       hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++;
+               }
+               /* fill the rest of the slots with ALSA channel 0xf */
+               for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++)
+                       if (!ch_alloc->speakers[7 - hdmi_slot])
+                               hdmi_channel_mapping[ca][i++] = (0xf << 4) | hdmi_slot;
        }
 
        if (non_pcm) {
-               for (i = 0; i < channel_allocations[order].channels; i++)
-                       non_pcm_mapping[i] = i | (i << 4);
+               for (i = 0; i < ch_alloc->channels; i++)
+                       non_pcm_mapping[i] = (i << 4) | i;
                for (; i < 8; i++)
-                       non_pcm_mapping[i] = 0xf | (i << 4);
+                       non_pcm_mapping[i] = (0xf << 4) | i;
        }
 
        for (i = 0; i < 8; i++) {
-               err = snd_hda_codec_write(codec, pin_nid, 0,
-                                         AC_VERB_SET_HDMI_CHAN_SLOT,
-                                         non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]);
+               int slotsetup = non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i];
+               int hdmi_slot = slotsetup & 0x0f;
+               int channel = (slotsetup & 0xf0) >> 4;
+               err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, channel);
                if (err) {
                        snd_printdd(KERN_NOTICE
                                    "HDMI: channel mapping failed\n");
                        break;
                }
        }
-
-       hdmi_debug_channel_mapping(codec, pin_nid);
 }
 
 struct channel_map_table {
        unsigned char map;              /* ALSA API channel map position */
-       unsigned char cea_slot;         /* CEA slot value */
        int spk_mask;                   /* speaker position bit mask */
 };
 
 static struct channel_map_table map_tables[] = {
-       { SNDRV_CHMAP_FL,       0x00,   FL },
-       { SNDRV_CHMAP_FR,       0x01,   FR },
-       { SNDRV_CHMAP_RL,       0x04,   RL },
-       { SNDRV_CHMAP_RR,       0x05,   RR },
-       { SNDRV_CHMAP_LFE,      0x02,   LFE },
-       { SNDRV_CHMAP_FC,       0x03,   FC },
-       { SNDRV_CHMAP_RLC,      0x06,   RLC },
-       { SNDRV_CHMAP_RRC,      0x07,   RRC },
+       { SNDRV_CHMAP_FL,       FL },
+       { SNDRV_CHMAP_FR,       FR },
+       { SNDRV_CHMAP_RL,       RL },
+       { SNDRV_CHMAP_RR,       RR },
+       { SNDRV_CHMAP_LFE,      LFE },
+       { SNDRV_CHMAP_FC,       FC },
+       { SNDRV_CHMAP_RLC,      RLC },
+       { SNDRV_CHMAP_RRC,      RRC },
+       { SNDRV_CHMAP_RC,       RC },
+       { SNDRV_CHMAP_FLC,      FLC },
+       { SNDRV_CHMAP_FRC,      FRC },
+       { SNDRV_CHMAP_FLH,      FLH },
+       { SNDRV_CHMAP_FRH,      FRH },
+       { SNDRV_CHMAP_FLW,      FLW },
+       { SNDRV_CHMAP_FRW,      FRW },
+       { SNDRV_CHMAP_TC,       TC },
+       { SNDRV_CHMAP_FCH,      FCH },
        {} /* terminator */
 };
 
@@ -660,25 +783,19 @@ static int to_spk_mask(unsigned char c)
 }
 
 /* from ALSA API channel position to CEA slot */
-static int to_cea_slot(unsigned char c)
+static int to_cea_slot(int ordered_ca, unsigned char pos)
 {
-       struct channel_map_table *t = map_tables;
-       for (; t->map; t++) {
-               if (t->map == c)
-                       return t->cea_slot;
-       }
-       return 0x0f;
-}
+       int mask = to_spk_mask(pos);
+       int i;
 
-/* from CEA slot to ALSA API channel position */
-static int from_cea_slot(unsigned char c)
-{
-       struct channel_map_table *t = map_tables;
-       for (; t->map; t++) {
-               if (t->cea_slot == c)
-                       return t->map;
+       if (mask) {
+               for (i = 0; i < 8; i++) {
+                       if (channel_allocations[ordered_ca].speakers[7 - i] == mask)
+                               return i;
+               }
        }
-       return 0;
+
+       return -1;
 }
 
 /* from speaker bit mask to ALSA API channel position */
@@ -692,6 +809,14 @@ static int spk_to_chmap(int spk)
        return 0;
 }
 
+/* from CEA slot to ALSA API channel position */
+static int from_cea_slot(int ordered_ca, unsigned char slot)
+{
+       int mask = channel_allocations[ordered_ca].speakers[7 - slot];
+
+       return spk_to_chmap(mask);
+}
+
 /* get the CA index corresponding to the given ALSA API channel map */
 static int hdmi_manual_channel_allocation(int chs, unsigned char *map)
 {
@@ -718,18 +843,29 @@ static int hdmi_manual_channel_allocation(int chs, unsigned char *map)
 /* set up the channel slots for the given ALSA API channel map */
 static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec,
                                             hda_nid_t pin_nid,
-                                            int chs, unsigned char *map)
+                                            int chs, unsigned char *map,
+                                            int ca)
 {
-       int i;
-       for (i = 0; i < 8; i++) {
-               int val, err;
-               if (i < chs)
-                       val = to_cea_slot(map[i]);
-               else
-                       val = 0xf;
-               val |= (i << 4);
-               err = snd_hda_codec_write(codec, pin_nid, 0,
-                                         AC_VERB_SET_HDMI_CHAN_SLOT, val);
+       struct hdmi_spec *spec = codec->spec;
+       int ordered_ca = get_channel_allocation_order(ca);
+       int alsa_pos, hdmi_slot;
+       int assignments[8] = {[0 ... 7] = 0xf};
+
+       for (alsa_pos = 0; alsa_pos < chs; alsa_pos++) {
+
+               hdmi_slot = to_cea_slot(ordered_ca, map[alsa_pos]);
+
+               if (hdmi_slot < 0)
+                       continue; /* unassigned channel */
+
+               assignments[hdmi_slot] = alsa_pos;
+       }
+
+       for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++) {
+               int err;
+
+               err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot,
+                                                    assignments[hdmi_slot]);
                if (err)
                        return -EINVAL;
        }
@@ -740,9 +876,10 @@ static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec,
 static void hdmi_setup_fake_chmap(unsigned char *map, int ca)
 {
        int i;
+       int ordered_ca = get_channel_allocation_order(ca);
        for (i = 0; i < 8; i++) {
-               if (i < channel_allocations[ca].channels)
-                       map[i] = from_cea_slot((hdmi_channel_mapping[ca][i] >> 4) & 0x0f);
+               if (i < channel_allocations[ordered_ca].channels)
+                       map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f);
                else
                        map[i] = 0;
        }
@@ -755,11 +892,29 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec,
 {
        if (!non_pcm && chmap_set) {
                hdmi_manual_setup_channel_mapping(codec, pin_nid,
-                                                 channels, map);
+                                                 channels, map, ca);
        } else {
                hdmi_std_setup_channel_mapping(codec, pin_nid, non_pcm, ca);
                hdmi_setup_fake_chmap(map, ca);
        }
+
+       hdmi_debug_channel_mapping(codec, pin_nid);
+}
+
+static int hdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid,
+                                    int asp_slot, int channel)
+{
+       return snd_hda_codec_write(codec, pin_nid, 0,
+                                  AC_VERB_SET_HDMI_CHAN_SLOT,
+                                  (channel << 4) | asp_slot);
+}
+
+static int hdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid,
+                                    int asp_slot)
+{
+       return (snd_hda_codec_read(codec, pin_nid, 0,
+                                  AC_VERB_GET_HDMI_CHAN_SLOT,
+                                  asp_slot) & 0xf0) >> 4;
 }
 
 /*
@@ -883,15 +1038,64 @@ static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid,
        return true;
 }
 
+static void hdmi_pin_setup_infoframe(struct hda_codec *codec,
+                                    hda_nid_t pin_nid,
+                                    int ca, int active_channels,
+                                    int conn_type)
+{
+       union audio_infoframe ai;
+
+       if (conn_type == 0) { /* HDMI */
+               struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi;
+
+               hdmi_ai->type           = 0x84;
+               hdmi_ai->ver            = 0x01;
+               hdmi_ai->len            = 0x0a;
+               hdmi_ai->CC02_CT47      = active_channels - 1;
+               hdmi_ai->CA             = ca;
+               hdmi_checksum_audio_infoframe(hdmi_ai);
+       } else if (conn_type == 1) { /* DisplayPort */
+               struct dp_audio_infoframe *dp_ai = &ai.dp;
+
+               dp_ai->type             = 0x84;
+               dp_ai->len              = 0x1b;
+               dp_ai->ver              = 0x11 << 2;
+               dp_ai->CC02_CT47        = active_channels - 1;
+               dp_ai->CA               = ca;
+       } else {
+               snd_printd("HDMI: unknown connection type at pin %d\n",
+                           pin_nid);
+               return;
+       }
+
+       /*
+        * sizeof(ai) is used instead of sizeof(*hdmi_ai) or
+        * sizeof(*dp_ai) to avoid partial match/update problems when
+        * the user switches between HDMI/DP monitors.
+        */
+       if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
+                                       sizeof(ai))) {
+               snd_printdd("hdmi_pin_setup_infoframe: "
+                           "pin=%d channels=%d ca=0x%02x\n",
+                           pin_nid,
+                           active_channels, ca);
+               hdmi_stop_infoframe_trans(codec, pin_nid);
+               hdmi_fill_audio_infoframe(codec, pin_nid,
+                                           ai.bytes, sizeof(ai));
+               hdmi_start_infoframe_trans(codec, pin_nid);
+       }
+}
+
 static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
                                       struct hdmi_spec_per_pin *per_pin,
                                       bool non_pcm)
 {
+       struct hdmi_spec *spec = codec->spec;
        hda_nid_t pin_nid = per_pin->pin_nid;
        int channels = per_pin->channels;
+       int active_channels;
        struct hdmi_eld *eld;
-       int ca;
-       union audio_infoframe ai;
+       int ca, ordered_ca;
 
        if (!channels)
                return;
@@ -912,29 +1116,10 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
        if (ca < 0)
                ca = 0;
 
-       memset(&ai, 0, sizeof(ai));
-       if (eld->info.conn_type == 0) { /* HDMI */
-               struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi;
+       ordered_ca = get_channel_allocation_order(ca);
+       active_channels = channel_allocations[ordered_ca].channels;
 
-               hdmi_ai->type           = 0x84;
-               hdmi_ai->ver            = 0x01;
-               hdmi_ai->len            = 0x0a;
-               hdmi_ai->CC02_CT47      = channels - 1;
-               hdmi_ai->CA             = ca;
-               hdmi_checksum_audio_infoframe(hdmi_ai);
-       } else if (eld->info.conn_type == 1) { /* DisplayPort */
-               struct dp_audio_infoframe *dp_ai = &ai.dp;
-
-               dp_ai->type             = 0x84;
-               dp_ai->len              = 0x1b;
-               dp_ai->ver              = 0x11 << 2;
-               dp_ai->CC02_CT47        = channels - 1;
-               dp_ai->CA               = ca;
-       } else {
-               snd_printd("HDMI: unknown connection type at pin %d\n",
-                           pin_nid);
-               return;
-       }
+       hdmi_set_channel_count(codec, per_pin->cvt_nid, active_channels);
 
        /*
         * always configure channel mapping, it may have been changed by the
@@ -944,27 +1129,12 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
                                   channels, per_pin->chmap,
                                   per_pin->chmap_set);
 
-       /*
-        * sizeof(ai) is used instead of sizeof(*hdmi_ai) or
-        * sizeof(*dp_ai) to avoid partial match/update problems when
-        * the user switches between HDMI/DP monitors.
-        */
-       if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
-                                       sizeof(ai))) {
-               snd_printdd("hdmi_setup_audio_infoframe: "
-                           "pin=%d channels=%d\n",
-                           pin_nid,
-                           channels);
-               hdmi_stop_infoframe_trans(codec, pin_nid);
-               hdmi_fill_audio_infoframe(codec, pin_nid,
-                                           ai.bytes, sizeof(ai));
-               hdmi_start_infoframe_trans(codec, pin_nid);
-       }
+       spec->ops.pin_setup_infoframe(codec, pin_nid, ca, active_channels,
+                                     eld->info.conn_type);
 
        per_pin->non_pcm = non_pcm;
 }
 
-
 /*
  * Unsolicited events
  */
@@ -1067,26 +1237,22 @@ static void haswell_verify_D0(struct hda_codec *codec,
 #define is_hbr_format(format) \
        ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7)
 
-static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
-                             hda_nid_t pin_nid, u32 stream_tag, int format)
+static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
+                             bool hbr)
 {
-       int pinctl;
-       int new_pinctl = 0;
-
-       if (is_haswell(codec))
-               haswell_verify_D0(codec, cvt_nid, pin_nid);
+       int pinctl, new_pinctl;
 
        if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) {
                pinctl = snd_hda_codec_read(codec, pin_nid, 0,
                                            AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
 
                new_pinctl = pinctl & ~AC_PINCTL_EPT;
-               if (is_hbr_format(format))
+               if (hbr)
                        new_pinctl |= AC_PINCTL_EPT_HBR;
                else
                        new_pinctl |= AC_PINCTL_EPT_NATIVE;
 
-               snd_printdd("hdmi_setup_stream: "
+               snd_printdd("hdmi_pin_hbr_setup: "
                            "NID=0x%x, %spinctl=0x%x\n",
                            pin_nid,
                            pinctl == new_pinctl ? "" : "new-",
@@ -1096,11 +1262,26 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
                        snd_hda_codec_write(codec, pin_nid, 0,
                                            AC_VERB_SET_PIN_WIDGET_CONTROL,
                                            new_pinctl);
+       } else if (hbr)
+               return -EINVAL;
 
-       }
-       if (is_hbr_format(format) && !new_pinctl) {
+       return 0;
+}
+
+static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
+                             hda_nid_t pin_nid, u32 stream_tag, int format)
+{
+       struct hdmi_spec *spec = codec->spec;
+       int err;
+
+       if (is_haswell(codec))
+               haswell_verify_D0(codec, cvt_nid, pin_nid);
+
+       err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format));
+
+       if (err) {
                snd_printdd("hdmi_setup_stream: HBR is not supported\n");
-               return -EINVAL;
+               return err;
        }
 
        snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format);
@@ -1217,6 +1398,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
        per_cvt = get_cvt(spec, cvt_idx);
        /* Claim converter */
        per_cvt->assigned = 1;
+       per_pin->cvt_nid = per_cvt->cvt_nid;
        hinfo->nid = per_cvt->cvt_nid;
 
        snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
@@ -1302,6 +1484,7 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
        bool update_eld = false;
        bool eld_changed = false;
 
+       mutex_lock(&per_pin->lock);
        pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
        if (pin_eld->monitor_present)
                eld->eld_valid  = !!(present & AC_PINSENSE_ELDV);
@@ -1313,7 +1496,7 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
                codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid);
 
        if (eld->eld_valid) {
-               if (snd_hdmi_get_eld(codec, pin_nid, eld->eld_buffer,
+               if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer,
                                                     &eld->eld_size) < 0)
                        eld->eld_valid = false;
                else {
@@ -1331,11 +1514,10 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
                        queue_delayed_work(codec->bus->workq,
                                           &per_pin->work,
                                           msecs_to_jiffies(300));
-                       return;
+                       goto unlock;
                }
        }
 
-       mutex_lock(&pin_eld->lock);
        if (pin_eld->eld_valid && !eld->eld_valid) {
                update_eld = true;
                eld_changed = true;
@@ -1352,20 +1534,22 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
                pin_eld->eld_size = eld->eld_size;
                pin_eld->info = eld->info;
 
-               /* Haswell-specific workaround: re-setup when the transcoder is
-                * changed during the stream playback
+               /*
+                * Re-setup pin and infoframe. This is needed e.g. when
+                * - sink is first plugged-in (infoframe is not set up if !monitor_present)
+                * - transcoder can change during stream playback on Haswell
                 */
-               if (is_haswell(codec) &&
-                   eld->eld_valid && !old_eld_valid && per_pin->setup)
+               if (eld->eld_valid && !old_eld_valid && per_pin->setup)
                        hdmi_setup_audio_infoframe(codec, per_pin,
                                                   per_pin->non_pcm);
        }
-       mutex_unlock(&pin_eld->lock);
 
        if (eld_changed)
                snd_ctl_notify(codec->bus->card,
                               SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO,
                               &per_pin->eld_ctl->id);
+ unlock:
+       mutex_unlock(&per_pin->lock);
 }
 
 static void hdmi_repoll_eld(struct work_struct *work)
@@ -1536,14 +1720,14 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
        bool non_pcm;
 
        non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
+       mutex_lock(&per_pin->lock);
        per_pin->channels = substream->runtime->channels;
        per_pin->setup = true;
 
-       hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels);
-
        hdmi_setup_audio_infoframe(codec, per_pin, non_pcm);
+       mutex_unlock(&per_pin->lock);
 
-       return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
+       return spec->ops.setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
 }
 
 static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
@@ -1579,11 +1763,14 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
                per_pin = get_pin(spec, pin_idx);
 
                snd_hda_spdif_ctls_unassign(codec, pin_idx);
+
+               mutex_lock(&per_pin->lock);
                per_pin->chmap_set = false;
                memset(per_pin->chmap, 0, sizeof(per_pin->chmap));
 
                per_pin->setup = false;
                per_pin->channels = 0;
+               mutex_unlock(&per_pin->lock);
        }
 
        return 0;
@@ -1612,14 +1799,40 @@ static int hdmi_chmap_ctl_info(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
+static int hdmi_chmap_cea_alloc_validate_get_type(struct cea_channel_speaker_allocation *cap,
+                                                 int channels)
+{
+       /* If the speaker allocation matches the channel count, it is OK.*/
+       if (cap->channels != channels)
+               return -1;
+
+       /* all channels are remappable freely */
+       return SNDRV_CTL_TLVT_CHMAP_VAR;
+}
+
+static void hdmi_cea_alloc_to_tlv_chmap(struct cea_channel_speaker_allocation *cap,
+                                       unsigned int *chmap, int channels)
+{
+       int count = 0;
+       int c;
+
+       for (c = 7; c >= 0; c--) {
+               int spk = cap->speakers[c];
+               if (!spk)
+                       continue;
+
+               chmap[count++] = spk_to_chmap(spk);
+       }
+
+       WARN_ON(count != channels);
+}
+
 static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
                              unsigned int size, unsigned int __user *tlv)
 {
        struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
        struct hda_codec *codec = info->private_data;
        struct hdmi_spec *spec = codec->spec;
-       const unsigned int valid_mask =
-               FL | FR | RL | RR | LFE | FC | RLC | RRC;
        unsigned int __user *dst;
        int chs, count = 0;
 
@@ -1630,18 +1843,19 @@ static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
        size -= 8;
        dst = tlv + 2;
        for (chs = 2; chs <= spec->channels_max; chs++) {
-               int i, c;
+               int i;
                struct cea_channel_speaker_allocation *cap;
                cap = channel_allocations;
                for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) {
                        int chs_bytes = chs * 4;
-                       if (cap->channels != chs)
-                               continue;
-                       if (cap->spk_mask & ~valid_mask)
+                       int type = spec->ops.chmap_cea_alloc_validate_get_type(cap, chs);
+                       unsigned int tlv_chmap[8];
+
+                       if (type < 0)
                                continue;
                        if (size < 8)
                                return -ENOMEM;
-                       if (put_user(SNDRV_CTL_TLVT_CHMAP_VAR, dst) ||
+                       if (put_user(type, dst) ||
                            put_user(chs_bytes, dst + 1))
                                return -EFAULT;
                        dst += 2;
@@ -1651,14 +1865,10 @@ static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
                                return -ENOMEM;
                        size -= chs_bytes;
                        count += chs_bytes;
-                       for (c = 7; c >= 0; c--) {
-                               int spk = cap->speakers[c];
-                               if (!spk)
-                                       continue;
-                               if (put_user(spk_to_chmap(spk), dst))
-                                       return -EFAULT;
-                               dst++;
-                       }
+                       spec->ops.cea_alloc_to_tlv_chmap(cap, tlv_chmap, chs);
+                       if (copy_to_user(dst, tlv_chmap, chs_bytes))
+                               return -EFAULT;
+                       dst += chs;
                }
        }
        if (put_user(count, tlv + 1))
@@ -1692,7 +1902,7 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol,
        unsigned int ctl_idx;
        struct snd_pcm_substream *substream;
        unsigned char chmap[8];
-       int i, ca, prepared = 0;
+       int i, err, ca, prepared = 0;
 
        ctl_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
        substream = snd_pcm_chmap_substream(info, ctl_idx);
@@ -1716,10 +1926,17 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol,
        ca = hdmi_manual_channel_allocation(ARRAY_SIZE(chmap), chmap);
        if (ca < 0)
                return -EINVAL;
+       if (spec->ops.chmap_validate) {
+               err = spec->ops.chmap_validate(ca, ARRAY_SIZE(chmap), chmap);
+               if (err)
+                       return err;
+       }
+       mutex_lock(&per_pin->lock);
        per_pin->chmap_set = true;
        memcpy(per_pin->chmap, chmap, sizeof(chmap));
        if (prepared)
                hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm);
+       mutex_unlock(&per_pin->lock);
 
        return 0;
 }
@@ -1836,12 +2053,11 @@ static int generic_hdmi_init_per_pins(struct hda_codec *codec)
 
        for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
                struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
-               struct hdmi_eld *eld = &per_pin->sink_eld;
 
                per_pin->codec = codec;
-               mutex_init(&eld->lock);
+               mutex_init(&per_pin->lock);
                INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld);
-               snd_hda_eld_proc_new(codec, eld, pin_idx);
+               eld_proc_new(per_pin, pin_idx);
        }
        return 0;
 }
@@ -1882,10 +2098,9 @@ static void generic_hdmi_free(struct hda_codec *codec)
 
        for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
                struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
-               struct hdmi_eld *eld = &per_pin->sink_eld;
 
                cancel_delayed_work(&per_pin->work);
-               snd_hda_eld_proc_free(codec, eld);
+               eld_proc_free(per_pin);
        }
 
        flush_workqueue(codec->bus->workq);
@@ -1922,6 +2137,17 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = {
 #endif
 };
 
+static const struct hdmi_ops generic_standard_hdmi_ops = {
+       .pin_get_eld                            = snd_hdmi_get_eld,
+       .pin_get_slot_channel                   = hdmi_pin_get_slot_channel,
+       .pin_set_slot_channel                   = hdmi_pin_set_slot_channel,
+       .pin_setup_infoframe                    = hdmi_pin_setup_infoframe,
+       .pin_hbr_setup                          = hdmi_pin_hbr_setup,
+       .setup_stream                           = hdmi_setup_stream,
+       .chmap_cea_alloc_validate_get_type      = hdmi_chmap_cea_alloc_validate_get_type,
+       .cea_alloc_to_tlv_chmap                 = hdmi_cea_alloc_to_tlv_chmap,
+};
+
 
 static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
                                             hda_nid_t nid)
@@ -2004,6 +2230,7 @@ static int patch_generic_hdmi(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       spec->ops = generic_standard_hdmi_ops;
        codec->spec = spec;
        hdmi_array_init(spec, 4);
 
@@ -2559,49 +2786,358 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
 }
 
 /*
- * ATI-specific implementations
- *
- * FIXME: we may omit the whole this and use the generic code once after
- * it's confirmed to work.
+ * ATI/AMD-specific implementations
  */
 
-#define ATIHDMI_CVT_NID                0x02    /* audio converter */
-#define ATIHDMI_PIN_NID                0x03    /* HDMI output pin */
+#define is_amdhdmi_rev3_or_later(codec) \
+       ((codec)->vendor_id == 0x1002aa01 && ((codec)->revision_id & 0xff00) >= 0x0300)
+#define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec)
 
-static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
-                                       struct hda_codec *codec,
-                                       unsigned int stream_tag,
-                                       unsigned int format,
-                                       struct snd_pcm_substream *substream)
+/* ATI/AMD specific HDA pin verbs, see the AMD HDA Verbs specification */
+#define ATI_VERB_SET_CHANNEL_ALLOCATION        0x771
+#define ATI_VERB_SET_DOWNMIX_INFO      0x772
+#define ATI_VERB_SET_MULTICHANNEL_01   0x777
+#define ATI_VERB_SET_MULTICHANNEL_23   0x778
+#define ATI_VERB_SET_MULTICHANNEL_45   0x779
+#define ATI_VERB_SET_MULTICHANNEL_67   0x77a
+#define ATI_VERB_SET_HBR_CONTROL       0x77c
+#define ATI_VERB_SET_MULTICHANNEL_1    0x785
+#define ATI_VERB_SET_MULTICHANNEL_3    0x786
+#define ATI_VERB_SET_MULTICHANNEL_5    0x787
+#define ATI_VERB_SET_MULTICHANNEL_7    0x788
+#define ATI_VERB_SET_MULTICHANNEL_MODE 0x789
+#define ATI_VERB_GET_CHANNEL_ALLOCATION        0xf71
+#define ATI_VERB_GET_DOWNMIX_INFO      0xf72
+#define ATI_VERB_GET_MULTICHANNEL_01   0xf77
+#define ATI_VERB_GET_MULTICHANNEL_23   0xf78
+#define ATI_VERB_GET_MULTICHANNEL_45   0xf79
+#define ATI_VERB_GET_MULTICHANNEL_67   0xf7a
+#define ATI_VERB_GET_HBR_CONTROL       0xf7c
+#define ATI_VERB_GET_MULTICHANNEL_1    0xf85
+#define ATI_VERB_GET_MULTICHANNEL_3    0xf86
+#define ATI_VERB_GET_MULTICHANNEL_5    0xf87
+#define ATI_VERB_GET_MULTICHANNEL_7    0xf88
+#define ATI_VERB_GET_MULTICHANNEL_MODE 0xf89
+
+/* AMD specific HDA cvt verbs */
+#define ATI_VERB_SET_RAMP_RATE         0x770
+#define ATI_VERB_GET_RAMP_RATE         0xf70
+
+#define ATI_OUT_ENABLE 0x1
+
+#define ATI_MULTICHANNEL_MODE_PAIRED   0
+#define ATI_MULTICHANNEL_MODE_SINGLE   1
+
+#define ATI_HBR_CAPABLE 0x01
+#define ATI_HBR_ENABLE 0x10
+
+static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid,
+                          unsigned char *buf, int *eld_size)
+{
+       /* call hda_eld.c ATI/AMD-specific function */
+       return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size,
+                                   is_amdhdmi_rev3_or_later(codec));
+}
+
+static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, int ca,
+                                       int active_channels, int conn_type)
+{
+       snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca);
+}
+
+static int atihdmi_paired_swap_fc_lfe(int pos)
+{
+       /*
+        * ATI/AMD have automatic FC/LFE swap built-in
+        * when in pairwise mapping mode.
+        */
+
+       switch (pos) {
+               /* see channel_allocations[].speakers[] */
+               case 2: return 3;
+               case 3: return 2;
+               default: break;
+       }
+
+       return pos;
+}
+
+static int atihdmi_paired_chmap_validate(int ca, int chs, unsigned char *map)
+{
+       struct cea_channel_speaker_allocation *cap;
+       int i, j;
+
+       /* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */
+
+       cap = &channel_allocations[get_channel_allocation_order(ca)];
+       for (i = 0; i < chs; ++i) {
+               int mask = to_spk_mask(map[i]);
+               bool ok = false;
+               bool companion_ok = false;
+
+               if (!mask)
+                       continue;
+
+               for (j = 0 + i % 2; j < 8; j += 2) {
+                       int chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j);
+                       if (cap->speakers[chan_idx] == mask) {
+                               /* channel is in a supported position */
+                               ok = true;
+
+                               if (i % 2 == 0 && i + 1 < chs) {
+                                       /* even channel, check the odd companion */
+                                       int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1);
+                                       int comp_mask_req = to_spk_mask(map[i+1]);
+                                       int comp_mask_act = cap->speakers[comp_chan_idx];
+
+                                       if (comp_mask_req == comp_mask_act)
+                                               companion_ok = true;
+                                       else
+                                               return -EINVAL;
+                               }
+                               break;
+                       }
+               }
+
+               if (!ok)
+                       return -EINVAL;
+
+               if (companion_ok)
+                       i++; /* companion channel already checked */
+       }
+
+       return 0;
+}
+
+static int atihdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid,
+                                       int hdmi_slot, int stream_channel)
+{
+       int verb;
+       int ati_channel_setup = 0;
+
+       if (hdmi_slot > 7)
+               return -EINVAL;
+
+       if (!has_amd_full_remap_support(codec)) {
+               hdmi_slot = atihdmi_paired_swap_fc_lfe(hdmi_slot);
+
+               /* In case this is an odd slot but without stream channel, do not
+                * disable the slot since the corresponding even slot could have a
+                * channel. In case neither have a channel, the slot pair will be
+                * disabled when this function is called for the even slot. */
+               if (hdmi_slot % 2 != 0 && stream_channel == 0xf)
+                       return 0;
+
+               hdmi_slot -= hdmi_slot % 2;
+
+               if (stream_channel != 0xf)
+                       stream_channel -= stream_channel % 2;
+       }
+
+       verb = ATI_VERB_SET_MULTICHANNEL_01 + hdmi_slot/2 + (hdmi_slot % 2) * 0x00e;
+
+       /* ati_channel_setup format: [7..4] = stream_channel_id, [1] = mute, [0] = enable */
+
+       if (stream_channel != 0xf)
+               ati_channel_setup = (stream_channel << 4) | ATI_OUT_ENABLE;
+
+       return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup);
+}
+
+static int atihdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid,
+                                       int asp_slot)
+{
+       bool was_odd = false;
+       int ati_asp_slot = asp_slot;
+       int verb;
+       int ati_channel_setup;
+
+       if (asp_slot > 7)
+               return -EINVAL;
+
+       if (!has_amd_full_remap_support(codec)) {
+               ati_asp_slot = atihdmi_paired_swap_fc_lfe(asp_slot);
+               if (ati_asp_slot % 2 != 0) {
+                       ati_asp_slot -= 1;
+                       was_odd = true;
+               }
+       }
+
+       verb = ATI_VERB_GET_MULTICHANNEL_01 + ati_asp_slot/2 + (ati_asp_slot % 2) * 0x00e;
+
+       ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0);
+
+       if (!(ati_channel_setup & ATI_OUT_ENABLE))
+               return 0xf;
+
+       return ((ati_channel_setup & 0xf0) >> 4) + !!was_odd;
+}
+
+static int atihdmi_paired_chmap_cea_alloc_validate_get_type(struct cea_channel_speaker_allocation *cap,
+                                                           int channels)
+{
+       int c;
+
+       /*
+        * Pre-rev3 ATI/AMD codecs operate in a paired channel mode, so
+        * we need to take that into account (a single channel may take 2
+        * channel slots if we need to carry a silent channel next to it).
+        * On Rev3+ AMD codecs this function is not used.
+        */
+       int chanpairs = 0;
+
+       /* We only produce even-numbered channel count TLVs */
+       if ((channels % 2) != 0)
+               return -1;
+
+       for (c = 0; c < 7; c += 2) {
+               if (cap->speakers[c] || cap->speakers[c+1])
+                       chanpairs++;
+       }
+
+       if (chanpairs * 2 != channels)
+               return -1;
+
+       return SNDRV_CTL_TLVT_CHMAP_PAIRED;
+}
+
+static void atihdmi_paired_cea_alloc_to_tlv_chmap(struct cea_channel_speaker_allocation *cap,
+                                                 unsigned int *chmap, int channels)
+{
+       /* produce paired maps for pre-rev3 ATI/AMD codecs */
+       int count = 0;
+       int c;
+
+       for (c = 7; c >= 0; c--) {
+               int chan = 7 - atihdmi_paired_swap_fc_lfe(7 - c);
+               int spk = cap->speakers[chan];
+               if (!spk) {
+                       /* add N/A channel if the companion channel is occupied */
+                       if (cap->speakers[chan + (chan % 2 ? -1 : 1)])
+                               chmap[count++] = SNDRV_CHMAP_NA;
+
+                       continue;
+               }
+
+               chmap[count++] = spk_to_chmap(spk);
+       }
+
+       WARN_ON(count != channels);
+}
+
+static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
+                                bool hbr)
+{
+       int hbr_ctl, hbr_ctl_new;
+
+       hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0);
+       if (hbr_ctl & ATI_HBR_CAPABLE) {
+               if (hbr)
+                       hbr_ctl_new = hbr_ctl | ATI_HBR_ENABLE;
+               else
+                       hbr_ctl_new = hbr_ctl & ~ATI_HBR_ENABLE;
+
+               snd_printdd("atihdmi_pin_hbr_setup: "
+                               "NID=0x%x, %shbr-ctl=0x%x\n",
+                               pin_nid,
+                               hbr_ctl == hbr_ctl_new ? "" : "new-",
+                               hbr_ctl_new);
+
+               if (hbr_ctl != hbr_ctl_new)
+                       snd_hda_codec_write(codec, pin_nid, 0,
+                                               ATI_VERB_SET_HBR_CONTROL,
+                                               hbr_ctl_new);
+
+       } else if (hbr)
+               return -EINVAL;
+
+       return 0;
+}
+
+static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
+                               hda_nid_t pin_nid, u32 stream_tag, int format)
+{
+
+       if (is_amdhdmi_rev3_or_later(codec)) {
+               int ramp_rate = 180; /* default as per AMD spec */
+               /* disable ramp-up/down for non-pcm as per AMD spec */
+               if (format & AC_FMT_TYPE_NON_PCM)
+                       ramp_rate = 0;
+
+               snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate);
+       }
+
+       return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
+}
+
+
+static int atihdmi_init(struct hda_codec *codec)
 {
        struct hdmi_spec *spec = codec->spec;
-       struct hdmi_spec_per_cvt *per_cvt = get_cvt(spec, 0);
-       int chans = substream->runtime->channels;
-       int i, err;
+       int pin_idx, err;
 
-       err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format,
-                                         substream);
-       if (err < 0)
+       err = generic_hdmi_init(codec);
+
+       if (err)
                return err;
-       snd_hda_codec_write(codec, per_cvt->cvt_nid, 0,
-                           AC_VERB_SET_CVT_CHAN_COUNT, chans - 1);
-       /* FIXME: XXX */
-       for (i = 0; i < chans; i++) {
-               snd_hda_codec_write(codec, per_cvt->cvt_nid, 0,
-                                   AC_VERB_SET_HDMI_CHAN_SLOT,
-                                   (i << 4) | i);
+
+       for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
+               struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
+
+               /* make sure downmix information in infoframe is zero */
+               snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0);
+
+               /* enable channel-wise remap mode if supported */
+               if (has_amd_full_remap_support(codec))
+                       snd_hda_codec_write(codec, per_pin->pin_nid, 0,
+                                           ATI_VERB_SET_MULTICHANNEL_MODE,
+                                           ATI_MULTICHANNEL_MODE_SINGLE);
        }
+
        return 0;
 }
 
 static int patch_atihdmi(struct hda_codec *codec)
 {
        struct hdmi_spec *spec;
-       int err = patch_simple_hdmi(codec, ATIHDMI_CVT_NID, ATIHDMI_PIN_NID);
-       if (err < 0)
+       struct hdmi_spec_per_cvt *per_cvt;
+       int err, cvt_idx;
+
+       err = patch_generic_hdmi(codec);
+
+       if (err)
                return err;
+
+       codec->patch_ops.init = atihdmi_init;
+
        spec = codec->spec;
-       spec->pcm_playback.ops.prepare = atihdmi_playback_pcm_prepare;
+
+       spec->ops.pin_get_eld = atihdmi_pin_get_eld;
+       spec->ops.pin_get_slot_channel = atihdmi_pin_get_slot_channel;
+       spec->ops.pin_set_slot_channel = atihdmi_pin_set_slot_channel;
+       spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe;
+       spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup;
+       spec->ops.setup_stream = atihdmi_setup_stream;
+
+       if (!has_amd_full_remap_support(codec)) {
+               /* override to ATI/AMD-specific versions with pairwise mapping */
+               spec->ops.chmap_cea_alloc_validate_get_type =
+                       atihdmi_paired_chmap_cea_alloc_validate_get_type;
+               spec->ops.cea_alloc_to_tlv_chmap = atihdmi_paired_cea_alloc_to_tlv_chmap;
+               spec->ops.chmap_validate = atihdmi_paired_chmap_validate;
+       }
+
+       /* ATI/AMD converters do not advertise all of their capabilities */
+       for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) {
+               per_cvt = get_cvt(spec, cvt_idx);
+               per_cvt->channels_max = max(per_cvt->channels_max, 8u);
+               per_cvt->rates |= SUPPORTED_RATES;
+               per_cvt->formats |= SUPPORTED_FORMATS;
+               per_cvt->maxbps = max(per_cvt->maxbps, 24u);
+       }
+
+       spec->channels_max = max(spec->channels_max, 8u);
+
        return 0;
 }
 
@@ -2621,7 +3157,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
 { .id = 0x1002793c, .name = "RS600 HDMI",      .patch = patch_atihdmi },
 { .id = 0x10027919, .name = "RS600 HDMI",      .patch = patch_atihdmi },
 { .id = 0x1002791a, .name = "RS690/780 HDMI",  .patch = patch_atihdmi },
-{ .id = 0x1002aa01, .name = "R6xx HDMI",       .patch = patch_generic_hdmi },
+{ .id = 0x1002aa01, .name = "R6xx HDMI",       .patch = patch_atihdmi },
 { .id = 0x10951390, .name = "SiI1390 HDMI",    .patch = patch_generic_hdmi },
 { .id = 0x10951392, .name = "SiI1392 HDMI",    .patch = patch_generic_hdmi },
 { .id = 0x17e80047, .name = "Chrontel HDMI",   .patch = patch_generic_hdmi },
@@ -2669,6 +3205,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
 { .id = 0x80862806, .name = "PantherPoint HDMI", .patch = patch_generic_hdmi },
 { .id = 0x80862807, .name = "Haswell HDMI",    .patch = patch_generic_hdmi },
 { .id = 0x80862880, .name = "CedarTrail HDMI", .patch = patch_generic_hdmi },
+{ .id = 0x80862882, .name = "Valleyview2 HDMI",        .patch = patch_generic_hdmi },
 { .id = 0x808629fb, .name = "Crestline HDMI",  .patch = patch_generic_hdmi },
 {} /* terminator */
 };
@@ -2723,6 +3260,7 @@ MODULE_ALIAS("snd-hda-codec-id:80862805");
 MODULE_ALIAS("snd-hda-codec-id:80862806");
 MODULE_ALIAS("snd-hda-codec-id:80862807");
 MODULE_ALIAS("snd-hda-codec-id:80862880");
+MODULE_ALIAS("snd-hda-codec-id:80862882");
 MODULE_ALIAS("snd-hda-codec-id:808629fb");
 
 MODULE_LICENSE("GPL");
index bf313bea70858f8a4abd18ef6c60beca6668fea1..1f0a040a98182a48640bd01167fec4efb2ea4d43 100644 (file)
@@ -2539,7 +2539,9 @@ enum {
        ALC269_TYPE_ALC282,
        ALC269_TYPE_ALC283,
        ALC269_TYPE_ALC284,
+       ALC269_TYPE_ALC285,
        ALC269_TYPE_ALC286,
+       ALC269_TYPE_ALC255,
 };
 
 /*
@@ -2558,6 +2560,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
        case ALC269_TYPE_ALC269VC:
        case ALC269_TYPE_ALC280:
        case ALC269_TYPE_ALC284:
+       case ALC269_TYPE_ALC285:
                ssids = alc269va_ssids;
                break;
        case ALC269_TYPE_ALC269VB:
@@ -2565,6 +2568,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
        case ALC269_TYPE_ALC282:
        case ALC269_TYPE_ALC283:
        case ALC269_TYPE_ALC286:
+       case ALC269_TYPE_ALC255:
                ssids = alc269_ssids;
                break;
        default:
@@ -2652,7 +2656,7 @@ static void alc283_shutup(struct hda_codec *codec)
                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
 
        if (hp_pin_sense)
-               msleep(85);
+               msleep(100);
 
        snd_hda_codec_write(codec, hp_pin, 0,
                            AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
@@ -2661,7 +2665,7 @@ static void alc283_shutup(struct hda_codec *codec)
        alc_write_coef_idx(codec, 0x46, val | (3 << 12));
 
        if (hp_pin_sense)
-               msleep(85);
+               msleep(100);
        snd_hda_shutup_pins(codec);
        alc_write_coef_idx(codec, 0x43, 0x9614);
 }
@@ -4125,9 +4129,16 @@ static int patch_alc269(struct hda_codec *codec)
        case 0x10ec0292:
                spec->codec_variant = ALC269_TYPE_ALC284;
                break;
+       case 0x10ec0285:
+       case 0x10ec0293:
+               spec->codec_variant = ALC269_TYPE_ALC285;
+               break;
        case 0x10ec0286:
                spec->codec_variant = ALC269_TYPE_ALC286;
                break;
+       case 0x10ec0255:
+               spec->codec_variant = ALC269_TYPE_ALC255;
+               break;
        }
 
        if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
@@ -4841,6 +4852,7 @@ static int patch_alc680(struct hda_codec *codec)
 static const struct hda_codec_preset snd_hda_preset_realtek[] = {
        { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
        { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
+       { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
        { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
        { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
        { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
@@ -4854,9 +4866,11 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
        { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
        { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
        { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
+       { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 },
        { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
        { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
        { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
+       { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 },
        { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
          .patch = patch_alc861 },
        { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
index fba0cef1c47fff7a49632bf663402785e5cf24f8..69a549a8234507e9b4ee14576717d779d05ff6c1 100644 (file)
@@ -2091,8 +2091,10 @@ static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec,
 {
        struct sigmatel_spec *spec = codec->spec;
 
-       if (action == HDA_FIXUP_ACT_PRE_PROBE)
+       if (action == HDA_FIXUP_ACT_PRE_PROBE) {
                spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
+               codec->bus->avoid_link_reset = 1;
+       }
 }
 
 static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec,
index 3cde55b753e26086c13569dbee92847db02c8a9c..2907e68150cb1ca1adb0c40a5a573ef7af18394b 100644 (file)
@@ -3996,7 +3996,6 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm)
                                        return 1;
                        }
                        return 0;
-                       break;
                case AES32:
                        status = hdspm_read(hdspm, HDSPM_statusRegister);
                        if (status & HDSPM_tcoLockAes) {
@@ -4006,9 +4005,6 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm)
                                        return 1;
                        }
                        return 0;
-
-                       break;
-
                case RayDAT:
                case AIO:
                        status = hdspm_read(hdspm, HDSPM_RD_STATUS_1);
@@ -4018,7 +4014,6 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm)
                        if (status & 0x4000000)
                                return 1; /* Lock */
                        return 0; /* No signal */
-                       break;
 
                default:
                        break;
index 61a64d281905e4b8997bc2ae3eb42ce387de9e7c..8b9e70105dd28f5ccceabad1cd2ea414a97640a1 100644 (file)
@@ -1,5 +1,5 @@
 snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o
-snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o
+snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o
 
 ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),)
 snd-soc-core-objs += soc-generic-dmaengine-pcm.o
index 3109db7b9017cc08dd23ef6f9c70f9c605bcdf3e..612e5801003f018a27e3670f5a7e0a7bacac416d 100644 (file)
@@ -50,7 +50,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
        buf->area = dma_alloc_coherent(pcm->card->dev, size,
                        &buf->addr, GFP_KERNEL);
        pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%zu\n",
-                       (void *)buf->area, (void *)buf->addr, size);
+                       (void *)buf->area, (void *)(long)buf->addr, size);
 
        if (!buf->area)
                return -ENOMEM;
index bb53dea85b17eefc55090dfb4190ee5863337a2d..8697cedccd21240f76b4b5076ba6d0968a394d75 100644 (file)
@@ -777,7 +777,7 @@ static int asoc_ssc_init(struct device *dev)
        if (ret) {
                dev_err(dev, "Could not register PCM: %d\n", ret);
                goto err_unregister_dai;
-       };
+       }
 
        return 0;
 
index 7222380131ea60441a6e05335250385b567abb2b..b4e36901a40b0e238c759dd38dd8c455eed61f44 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/pinctrl/consumer.h>
 
 #include <sound/soc.h>
 
@@ -155,15 +154,8 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev)
        struct snd_soc_card *card = &atmel_asoc_wm8904_card;
        struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink;
        struct clk *clk_src;
-       struct pinctrl *pinctrl;
        int id, ret;
 
-       pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
-       if (IS_ERR(pinctrl)) {
-               dev_err(&pdev->dev, "failed to request pinctrl\n");
-               return PTR_ERR(pinctrl);
-       }
-
        card->dev = &pdev->dev;
        ret = atmel_asoc_wm8904_dt_init(pdev);
        if (ret) {
index 802717eccbd010d1a43f104e87004a28e56c3f30..f15bff1548f8fceb86c3f466201aab13107d9816 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
+#include <linux/of.h>
 
 #include <linux/atmel-ssc.h>
 
index 2c20f01e1f7e8b8d8d6d623bba45288e2bedeb1a..06f938deda15bd0d888e7e6140d54f10ec9331b5 100644 (file)
@@ -1,6 +1,6 @@
 config SND_EP93XX_SOC
        tristate "SoC Audio support for the Cirrus Logic EP93xx series"
-       depends on ARCH_EP93XX && SND_SOC
+       depends on (ARCH_EP93XX || COMPILE_TEST) && SND_SOC
        select SND_SOC_GENERIC_DMAENGINE_PCM
        help
          Say Y or M if you want to add support for codecs attached to
index 0e9f56e0d4b2e7e6031cb30ecd007c7da04ba693..cfe517e6800969ab64c91c563c7b5839fc46da66 100644 (file)
@@ -57,9 +57,22 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
        return false;
 }
 
+static struct dma_chan *ep93xx_compat_request_channel(
+       struct snd_soc_pcm_runtime *rtd,
+       struct snd_pcm_substream *substream)
+{
+       struct snd_dmaengine_dai_dma_data *dma_data;
+
+       dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
+
+       return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter,
+                                                dma_data);
+}
+
 static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
        .pcm_hardware = &ep93xx_pcm_hardware,
        .compat_filter_fn = ep93xx_pcm_dma_filter,
+       .compat_request_channel = ep93xx_compat_request_channel,
        .prealloc_buffer_size = 131072,
 };
 
index 259d1ac4492fc610a1454567bdabd52f56dbae5a..75d0ad5d2dcb38107934536ba7ef93410025c2f6 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mfd/88pm860x.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
+#include <linux/regmap.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -140,6 +141,7 @@ struct pm860x_priv {
        unsigned int            filter;
        struct snd_soc_codec    *codec;
        struct i2c_client       *i2c;
+       struct regmap           *regmap;
        struct pm860x_chip      *chip;
        struct pm860x_det       det;
 
@@ -269,48 +271,6 @@ static struct st_gain st_table[] = {
        {   -86, 29,  0}, {   -56, 30,  0}, {   -28, 31,  0}, {     0,  0,  0},
 };
 
-static int pm860x_volatile(unsigned int reg)
-{
-       BUG_ON(reg >= REG_CACHE_SIZE);
-
-       switch (reg) {
-       case PM860X_AUDIO_SUPPLIES_2:
-               return 1;
-       }
-
-       return 0;
-}
-
-static unsigned int pm860x_read_reg_cache(struct snd_soc_codec *codec,
-                                         unsigned int reg)
-{
-       unsigned char *cache = codec->reg_cache;
-
-       BUG_ON(reg >= REG_CACHE_SIZE);
-
-       if (pm860x_volatile(reg))
-               return cache[reg];
-
-       reg += REG_CACHE_BASE;
-
-       return pm860x_reg_read(codec->control_data, reg);
-}
-
-static int pm860x_write_reg_cache(struct snd_soc_codec *codec,
-                                 unsigned int reg, unsigned int value)
-{
-       unsigned char *cache = codec->reg_cache;
-
-       BUG_ON(reg >= REG_CACHE_SIZE);
-
-       if (!pm860x_volatile(reg))
-               cache[reg] = (unsigned char)value;
-
-       reg += REG_CACHE_BASE;
-
-       return pm860x_reg_write(codec->control_data, reg, value);
-}
-
 static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol,
                                   struct snd_ctl_elem_value *ucontrol)
 {
@@ -1169,6 +1129,7 @@ static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
 static int pm860x_set_bias_level(struct snd_soc_codec *codec,
                                 enum snd_soc_bias_level level)
 {
+       struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec);
        int data;
 
        switch (level) {
@@ -1182,17 +1143,17 @@ static int pm860x_set_bias_level(struct snd_soc_codec *codec,
                if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
                        /* Enable Audio PLL & Audio section */
                        data = AUDIO_PLL | AUDIO_SECTION_ON;
-                       pm860x_reg_write(codec->control_data, REG_MISC2, data);
+                       pm860x_reg_write(pm860x->i2c, REG_MISC2, data);
                        udelay(300);
                        data = AUDIO_PLL | AUDIO_SECTION_RESET
                                | AUDIO_SECTION_ON;
-                       pm860x_reg_write(codec->control_data, REG_MISC2, data);
+                       pm860x_reg_write(pm860x->i2c, REG_MISC2, data);
                }
                break;
 
        case SND_SOC_BIAS_OFF:
                data = AUDIO_PLL | AUDIO_SECTION_RESET | AUDIO_SECTION_ON;
-               pm860x_set_bits(codec->control_data, REG_MISC2, data, 0);
+               pm860x_set_bits(pm860x->i2c, REG_MISC2, data, 0);
                break;
        }
        codec->dapm.bias_level = level;
@@ -1322,17 +1283,17 @@ int pm860x_hs_jack_detect(struct snd_soc_codec *codec,
        pm860x->det.lo_shrt = lo_shrt;
 
        if (det & SND_JACK_HEADPHONE)
-               pm860x_set_bits(codec->control_data, REG_HS_DET,
+               pm860x_set_bits(pm860x->i2c, REG_HS_DET,
                                EN_HS_DET, EN_HS_DET);
        /* headset short detect */
        if (hs_shrt) {
                data = CLR_SHORT_HS2 | CLR_SHORT_HS1;
-               pm860x_set_bits(codec->control_data, REG_SHORTS, data, data);
+               pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data);
        }
        /* Lineout short detect */
        if (lo_shrt) {
                data = CLR_SHORT_LO2 | CLR_SHORT_LO1;
-               pm860x_set_bits(codec->control_data, REG_SHORTS, data, data);
+               pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data);
        }
 
        /* sync status */
@@ -1350,7 +1311,7 @@ int pm860x_mic_jack_detect(struct snd_soc_codec *codec,
        pm860x->det.mic_det = det;
 
        if (det & SND_JACK_MICROPHONE)
-               pm860x_set_bits(codec->control_data, REG_MIC_DET,
+               pm860x_set_bits(pm860x->i2c, REG_MIC_DET,
                                MICDET_MASK, MICDET_MASK);
 
        /* sync status */
@@ -1366,7 +1327,7 @@ static int pm860x_probe(struct snd_soc_codec *codec)
 
        pm860x->codec = codec;
 
-       codec->control_data = pm860x->i2c;
+       codec->control_data = pm860x->regmap;
 
        for (i = 0; i < 4; i++) {
                ret = request_threaded_irq(pm860x->irq[i], NULL,
@@ -1380,14 +1341,6 @@ static int pm860x_probe(struct snd_soc_codec *codec)
 
        pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
-       ret = pm860x_bulk_read(codec->control_data, REG_CACHE_BASE,
-                              REG_CACHE_SIZE, codec->reg_cache);
-       if (ret < 0) {
-               dev_err(codec->dev, "Failed to fill register cache: %d\n",
-                       ret);
-               goto out;
-       }
-
        return 0;
 
 out:
@@ -1410,10 +1363,6 @@ static int pm860x_remove(struct snd_soc_codec *codec)
 static struct snd_soc_codec_driver soc_codec_dev_pm860x = {
        .probe          = pm860x_probe,
        .remove         = pm860x_remove,
-       .read           = pm860x_read_reg_cache,
-       .write          = pm860x_write_reg_cache,
-       .reg_cache_size = REG_CACHE_SIZE,
-       .reg_word_size  = sizeof(u8),
        .set_bias_level = pm860x_set_bias_level,
 
        .controls = pm860x_snd_controls,
@@ -1439,6 +1388,8 @@ static int pm860x_codec_probe(struct platform_device *pdev)
        pm860x->chip = chip;
        pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client
                        : chip->companion;
+       pm860x->regmap = (chip->id == CHIP_PM8607) ? chip->regmap
+                       : chip->regmap_companion;
        platform_set_drvdata(pdev, pm860x);
 
        for (i = 0; i < 4; i++) {
index 3364ba4a36071677087b53bce314f8019cdbcb4a..f7282f4f4a7909e3a35e4af6f74d735d90c2f167 100644 (file)
 #ifndef __88PM860X_H
 #define __88PM860X_H
 
-/* The offset of these registers are 0xb0 */
-#define PM860X_PCM_IFACE_1             0x00
-#define PM860X_PCM_IFACE_2             0x01
-#define PM860X_PCM_IFACE_3             0x02
-#define PM860X_PCM_RATE                        0x03
-#define PM860X_EC_PATH                 0x04
-#define PM860X_SIDETONE_L_GAIN         0x05
-#define PM860X_SIDETONE_R_GAIN         0x06
-#define PM860X_SIDETONE_SHIFT          0x07
-#define PM860X_ADC_OFFSET_1            0x08
-#define PM860X_ADC_OFFSET_2            0x09
-#define PM860X_DMIC_DELAY              0x0a
+#define PM860X_PCM_IFACE_1             0xb0
+#define PM860X_PCM_IFACE_2             0xb1
+#define PM860X_PCM_IFACE_3             0xb2
+#define PM860X_PCM_RATE                        0xb3
+#define PM860X_EC_PATH                 0xb4
+#define PM860X_SIDETONE_L_GAIN         0xb5
+#define PM860X_SIDETONE_R_GAIN         0xb6
+#define PM860X_SIDETONE_SHIFT          0xb7
+#define PM860X_ADC_OFFSET_1            0xb8
+#define PM860X_ADC_OFFSET_2            0xb9
+#define PM860X_DMIC_DELAY              0xba
 
-#define PM860X_I2S_IFACE_1             0x0b
-#define PM860X_I2S_IFACE_2             0x0c
-#define PM860X_I2S_IFACE_3             0x0d
-#define PM860X_I2S_IFACE_4             0x0e
-#define PM860X_EQUALIZER_N0_1          0x0f
-#define PM860X_EQUALIZER_N0_2          0x10
-#define PM860X_EQUALIZER_N1_1          0x11
-#define PM860X_EQUALIZER_N1_2          0x12
-#define PM860X_EQUALIZER_D1_1          0x13
-#define PM860X_EQUALIZER_D1_2          0x14
-#define PM860X_LOFI_GAIN_LEFT          0x15
-#define PM860X_LOFI_GAIN_RIGHT         0x16
-#define PM860X_HIFIL_GAIN_LEFT         0x17
-#define PM860X_HIFIL_GAIN_RIGHT                0x18
-#define PM860X_HIFIR_GAIN_LEFT         0x19
-#define PM860X_HIFIR_GAIN_RIGHT                0x1a
-#define PM860X_DAC_OFFSET              0x1b
-#define PM860X_OFFSET_LEFT_1           0x1c
-#define PM860X_OFFSET_LEFT_2           0x1d
-#define PM860X_OFFSET_RIGHT_1          0x1e
-#define PM860X_OFFSET_RIGHT_2          0x1f
-#define PM860X_ADC_ANA_1               0x20
-#define PM860X_ADC_ANA_2               0x21
-#define PM860X_ADC_ANA_3               0x22
-#define PM860X_ADC_ANA_4               0x23
-#define PM860X_ANA_TO_ANA              0x24
-#define PM860X_HS1_CTRL                        0x25
-#define PM860X_HS2_CTRL                        0x26
-#define PM860X_LO1_CTRL                        0x27
-#define PM860X_LO2_CTRL                        0x28
-#define PM860X_EAR_CTRL_1              0x29
-#define PM860X_EAR_CTRL_2              0x2a
-#define PM860X_AUDIO_SUPPLIES_1                0x2b
-#define PM860X_AUDIO_SUPPLIES_2                0x2c
-#define PM860X_ADC_EN_1                        0x2d
-#define PM860X_ADC_EN_2                        0x2e
-#define PM860X_DAC_EN_1                        0x2f
-#define PM860X_DAC_EN_2                        0x31
-#define PM860X_AUDIO_CAL_1             0x32
-#define PM860X_AUDIO_CAL_2             0x33
-#define PM860X_AUDIO_CAL_3             0x34
-#define PM860X_AUDIO_CAL_4             0x35
-#define PM860X_AUDIO_CAL_5             0x36
-#define PM860X_ANA_INPUT_SEL_1         0x37
-#define PM860X_ANA_INPUT_SEL_2         0x38
+#define PM860X_I2S_IFACE_1             0xbb
+#define PM860X_I2S_IFACE_2             0xbc
+#define PM860X_I2S_IFACE_3             0xbd
+#define PM860X_I2S_IFACE_4             0xbe
+#define PM860X_EQUALIZER_N0_1          0xbf
+#define PM860X_EQUALIZER_N0_2          0xc0
+#define PM860X_EQUALIZER_N1_1          0xc1
+#define PM860X_EQUALIZER_N1_2          0xc2
+#define PM860X_EQUALIZER_D1_1          0xc3
+#define PM860X_EQUALIZER_D1_2          0xc4
+#define PM860X_LOFI_GAIN_LEFT          0xc5
+#define PM860X_LOFI_GAIN_RIGHT         0xc6
+#define PM860X_HIFIL_GAIN_LEFT         0xc7
+#define PM860X_HIFIL_GAIN_RIGHT                0xc8
+#define PM860X_HIFIR_GAIN_LEFT         0xc9
+#define PM860X_HIFIR_GAIN_RIGHT                0xca
+#define PM860X_DAC_OFFSET              0xcb
+#define PM860X_OFFSET_LEFT_1           0xcc
+#define PM860X_OFFSET_LEFT_2           0xcd
+#define PM860X_OFFSET_RIGHT_1          0xce
+#define PM860X_OFFSET_RIGHT_2          0xcf
+#define PM860X_ADC_ANA_1               0xd0
+#define PM860X_ADC_ANA_2               0xd1
+#define PM860X_ADC_ANA_3               0xd2
+#define PM860X_ADC_ANA_4               0xd3
+#define PM860X_ANA_TO_ANA              0xd4
+#define PM860X_HS1_CTRL                        0xd5
+#define PM860X_HS2_CTRL                        0xd6
+#define PM860X_LO1_CTRL                        0xd7
+#define PM860X_LO2_CTRL                        0xd8
+#define PM860X_EAR_CTRL_1              0xd9
+#define PM860X_EAR_CTRL_2              0xda
+#define PM860X_AUDIO_SUPPLIES_1                0xdb
+#define PM860X_AUDIO_SUPPLIES_2                0xdc
+#define PM860X_ADC_EN_1                        0xdd
+#define PM860X_ADC_EN_2                        0xde
+#define PM860X_DAC_EN_1                        0xdf
+#define PM860X_DAC_EN_2                        0xe1
+#define PM860X_AUDIO_CAL_1             0xe2
+#define PM860X_AUDIO_CAL_2             0xe3
+#define PM860X_AUDIO_CAL_3             0xe4
+#define PM860X_AUDIO_CAL_4             0xe5
+#define PM860X_AUDIO_CAL_5             0xe6
+#define PM860X_ANA_INPUT_SEL_1         0xe7
+#define PM860X_ANA_INPUT_SEL_2         0xe8
 
-#define PM860X_PCM_IFACE_4             0x39
-#define PM860X_I2S_IFACE_5             0x3a
+#define PM860X_PCM_IFACE_4             0xe9
+#define PM860X_I2S_IFACE_5             0xea
 
 #define PM860X_SHORTS                  0x3b
 #define PM860X_PLL_ADJ_1               0x3c
index 80555d7551e68018d5e66485eea1507b10c35b92..a0394a8f2257174738555b5cbf3b5901d5d5fd5b 100644 (file)
@@ -126,6 +126,8 @@ struct ab8500_codec_drvdata_dbg {
 
 /* Private data for AB8500 device-driver */
 struct ab8500_codec_drvdata {
+       struct regmap *regmap;
+
        /* Sidetone */
        long *sid_fir_values;
        enum sid_state sid_status;
@@ -166,49 +168,35 @@ static inline const char *amic_type_str(enum amic_type type)
  */
 
 /* Read a register from the audio-bank of AB8500 */
-static unsigned int ab8500_codec_read_reg(struct snd_soc_codec *codec,
-                                       unsigned int reg)
+static int ab8500_codec_read_reg(void *context, unsigned int reg,
+                                unsigned int *value)
 {
+       struct device *dev = context;
        int status;
-       unsigned int value = 0;
 
        u8 value8;
-       status = abx500_get_register_interruptible(codec->dev, AB8500_AUDIO,
-                                               reg, &value8);
-       if (status < 0) {
-               dev_err(codec->dev,
-                       "%s: ERROR: Register (0x%02x:0x%02x) read failed (%d).\n",
-                       __func__, (u8)AB8500_AUDIO, (u8)reg, status);
-       } else {
-               dev_dbg(codec->dev,
-                       "%s: Read 0x%02x from register 0x%02x:0x%02x\n",
-                       __func__, value8, (u8)AB8500_AUDIO, (u8)reg);
-               value = (unsigned int)value8;
-       }
+       status = abx500_get_register_interruptible(dev, AB8500_AUDIO,
+                                                  reg, &value8);
+       *value = (unsigned int)value8;
 
-       return value;
+       return status;
 }
 
 /* Write to a register in the audio-bank of AB8500 */
-static int ab8500_codec_write_reg(struct snd_soc_codec *codec,
-                               unsigned int reg, unsigned int value)
+static int ab8500_codec_write_reg(void *context, unsigned int reg,
+                                 unsigned int value)
 {
-       int status;
-
-       status = abx500_set_register_interruptible(codec->dev, AB8500_AUDIO,
-                                               reg, value);
-       if (status < 0)
-               dev_err(codec->dev,
-                       "%s: ERROR: Register (%02x:%02x) write failed (%d).\n",
-                       __func__, (u8)AB8500_AUDIO, (u8)reg, status);
-       else
-               dev_dbg(codec->dev,
-                       "%s: Wrote 0x%02x into register %02x:%02x\n",
-                       __func__, (u8)value, (u8)AB8500_AUDIO, (u8)reg);
+       struct device *dev = context;
 
-       return status;
+       return abx500_set_register_interruptible(dev, AB8500_AUDIO,
+                                                reg, value);
 }
 
+static const struct regmap_config ab8500_codec_regmap = {
+       .reg_read = ab8500_codec_read_reg,
+       .reg_write = ab8500_codec_write_reg,
+};
+
 /*
  * Controls - DAPM
  */
@@ -2485,9 +2473,13 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
 
        dev_dbg(dev, "%s: Enter.\n", __func__);
 
+       snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
+
        /* Setup AB8500 according to board-settings */
        pdata = dev_get_platdata(dev->parent);
 
+       codec->control_data = drvdata->regmap;
+
        if (np) {
                if (!pdata)
                        pdata = devm_kzalloc(dev,
@@ -2532,12 +2524,10 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
        }
 
        /* Override HW-defaults */
-       ab8500_codec_write_reg(codec,
-                               AB8500_ANACONF5,
-                               BIT(AB8500_ANACONF5_HSAUTOEN));
-       ab8500_codec_write_reg(codec,
-                               AB8500_SHORTCIRCONF,
-                               BIT(AB8500_SHORTCIRCONF_HSZCDDIS));
+       snd_soc_write(codec, AB8500_ANACONF5,
+                     BIT(AB8500_ANACONF5_HSAUTOEN));
+       snd_soc_write(codec, AB8500_SHORTCIRCONF,
+                     BIT(AB8500_SHORTCIRCONF_HSZCDDIS));
 
        /* Add filter controls */
        status = snd_soc_add_codec_controls(codec, ab8500_filter_controls,
@@ -2567,9 +2557,6 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
 
 static struct snd_soc_codec_driver ab8500_codec_driver = {
        .probe =                ab8500_codec_probe,
-       .read =                 ab8500_codec_read_reg,
-       .write =                ab8500_codec_write_reg,
-       .reg_word_size =        sizeof(u8),
        .controls =             ab8500_ctrls,
        .num_controls =         ARRAY_SIZE(ab8500_ctrls),
        .dapm_widgets =         ab8500_dapm_widgets,
@@ -2592,6 +2579,15 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev)
        drvdata->anc_status = ANC_UNCONFIGURED;
        dev_set_drvdata(&pdev->dev, drvdata);
 
+       drvdata->regmap = devm_regmap_init(&pdev->dev, NULL, &pdev->dev,
+                                          &ab8500_codec_regmap);
+       if (IS_ERR(drvdata->regmap)) {
+               status = PTR_ERR(drvdata->regmap);
+               dev_err(&pdev->dev, "%s: Failed to allocate regmap: %d\n",
+                       __func__, status);
+               return status;
+       }
+
        dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__);
        status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver,
                                ab8500_codec_dai,
@@ -2606,7 +2602,7 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev)
 
 static int ab8500_codec_driver_remove(struct platform_device *pdev)
 {
-       dev_info(&pdev->dev, "%s Enter.\n", __func__);
+       dev_dbg(&pdev->dev, "%s Enter.\n", __func__);
 
        snd_soc_unregister_codec(&pdev->dev);
 
index 1aa10ddf3a614ab73085d883daa06638bfdfb77c..59654b1e7f3fbcd1262dca4c1066e505980aee2b 100644 (file)
@@ -32,6 +32,7 @@ struct adau1373_dai {
 };
 
 struct adau1373 {
+       struct regmap *regmap;
        struct adau1373_dai dais[3];
 };
 
@@ -73,7 +74,6 @@ struct adau1373 {
 #define ADAU1373_PLL_CTRL4(x)  (0x2c + (x) * 7)
 #define ADAU1373_PLL_CTRL5(x)  (0x2d + (x) * 7)
 #define ADAU1373_PLL_CTRL6(x)  (0x2e + (x) * 7)
-#define ADAU1373_PLL_CTRL7(x)  (0x2f + (x) * 7)
 #define ADAU1373_HEADDECT      0x36
 #define ADAU1373_ADC_DAC_STATUS        0x37
 #define ADAU1373_ADC_CTRL      0x3c
@@ -152,37 +152,172 @@ struct adau1373 {
 #define ADAU1373_EP_CTRL_MICBIAS1_OFFSET 4
 #define ADAU1373_EP_CTRL_MICBIAS2_OFFSET 2
 
-static const uint8_t adau1373_default_regs[] = {
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x30 */
-       0x00, 0x00, 0x00, 0x80, 0x00, 0x01, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00, /* 0x40 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, /* 0x50 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0x80 */
-       0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00,
-       0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0x90 */
-       0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00,
-       0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0xa0 */
-       0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb0 */
-       0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0 */
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, /* 0xe0 */
-       0x00, 0x1f, 0x0f, 0x00, 0x00,
+static const struct reg_default adau1373_reg_defaults[] = {
+       { ADAU1373_INPUT_MODE,          0x00 },
+       { ADAU1373_AINL_CTRL(0),        0x00 },
+       { ADAU1373_AINR_CTRL(0),        0x00 },
+       { ADAU1373_AINL_CTRL(1),        0x00 },
+       { ADAU1373_AINR_CTRL(1),        0x00 },
+       { ADAU1373_AINL_CTRL(2),        0x00 },
+       { ADAU1373_AINR_CTRL(2),        0x00 },
+       { ADAU1373_AINL_CTRL(3),        0x00 },
+       { ADAU1373_AINR_CTRL(3),        0x00 },
+       { ADAU1373_LLINE_OUT(0),        0x00 },
+       { ADAU1373_RLINE_OUT(0),        0x00 },
+       { ADAU1373_LLINE_OUT(1),        0x00 },
+       { ADAU1373_RLINE_OUT(1),        0x00 },
+       { ADAU1373_LSPK_OUT,            0x00 },
+       { ADAU1373_RSPK_OUT,            0x00 },
+       { ADAU1373_LHP_OUT,             0x00 },
+       { ADAU1373_RHP_OUT,             0x00 },
+       { ADAU1373_ADC_GAIN,            0x00 },
+       { ADAU1373_LADC_MIXER,          0x00 },
+       { ADAU1373_RADC_MIXER,          0x00 },
+       { ADAU1373_LLINE1_MIX,          0x00 },
+       { ADAU1373_RLINE1_MIX,          0x00 },
+       { ADAU1373_LLINE2_MIX,          0x00 },
+       { ADAU1373_RLINE2_MIX,          0x00 },
+       { ADAU1373_LSPK_MIX,            0x00 },
+       { ADAU1373_RSPK_MIX,            0x00 },
+       { ADAU1373_LHP_MIX,             0x00 },
+       { ADAU1373_RHP_MIX,             0x00 },
+       { ADAU1373_EP_MIX,              0x00 },
+       { ADAU1373_HP_CTRL,             0x00 },
+       { ADAU1373_HP_CTRL2,            0x00 },
+       { ADAU1373_LS_CTRL,             0x00 },
+       { ADAU1373_EP_CTRL,             0x00 },
+       { ADAU1373_MICBIAS_CTRL1,       0x00 },
+       { ADAU1373_MICBIAS_CTRL2,       0x00 },
+       { ADAU1373_OUTPUT_CTRL,         0x00 },
+       { ADAU1373_PWDN_CTRL1,          0x00 },
+       { ADAU1373_PWDN_CTRL2,          0x00 },
+       { ADAU1373_PWDN_CTRL3,          0x00 },
+       { ADAU1373_DPLL_CTRL(0),        0x00 },
+       { ADAU1373_PLL_CTRL1(0),        0x00 },
+       { ADAU1373_PLL_CTRL2(0),        0x00 },
+       { ADAU1373_PLL_CTRL3(0),        0x00 },
+       { ADAU1373_PLL_CTRL4(0),        0x00 },
+       { ADAU1373_PLL_CTRL5(0),        0x00 },
+       { ADAU1373_PLL_CTRL6(0),        0x02 },
+       { ADAU1373_DPLL_CTRL(1),        0x00 },
+       { ADAU1373_PLL_CTRL1(1),        0x00 },
+       { ADAU1373_PLL_CTRL2(1),        0x00 },
+       { ADAU1373_PLL_CTRL3(1),        0x00 },
+       { ADAU1373_PLL_CTRL4(1),        0x00 },
+       { ADAU1373_PLL_CTRL5(1),        0x00 },
+       { ADAU1373_PLL_CTRL6(1),        0x02 },
+       { ADAU1373_HEADDECT,            0x00 },
+       { ADAU1373_ADC_CTRL,            0x00 },
+       { ADAU1373_CLK_SRC_DIV(0),      0x00 },
+       { ADAU1373_CLK_SRC_DIV(1),      0x00 },
+       { ADAU1373_DAI(0),              0x0a },
+       { ADAU1373_DAI(1),              0x0a },
+       { ADAU1373_DAI(2),              0x0a },
+       { ADAU1373_BCLKDIV(0),          0x00 },
+       { ADAU1373_BCLKDIV(1),          0x00 },
+       { ADAU1373_BCLKDIV(2),          0x00 },
+       { ADAU1373_SRC_RATIOA(0),       0x00 },
+       { ADAU1373_SRC_RATIOB(0),       0x00 },
+       { ADAU1373_SRC_RATIOA(1),       0x00 },
+       { ADAU1373_SRC_RATIOB(1),       0x00 },
+       { ADAU1373_SRC_RATIOA(2),       0x00 },
+       { ADAU1373_SRC_RATIOB(2),       0x00 },
+       { ADAU1373_DEEMP_CTRL,          0x00 },
+       { ADAU1373_SRC_DAI_CTRL(0),     0x08 },
+       { ADAU1373_SRC_DAI_CTRL(1),     0x08 },
+       { ADAU1373_SRC_DAI_CTRL(2),     0x08 },
+       { ADAU1373_DIN_MIX_CTRL(0),     0x00 },
+       { ADAU1373_DIN_MIX_CTRL(1),     0x00 },
+       { ADAU1373_DIN_MIX_CTRL(2),     0x00 },
+       { ADAU1373_DIN_MIX_CTRL(3),     0x00 },
+       { ADAU1373_DIN_MIX_CTRL(4),     0x00 },
+       { ADAU1373_DOUT_MIX_CTRL(0),    0x00 },
+       { ADAU1373_DOUT_MIX_CTRL(1),    0x00 },
+       { ADAU1373_DOUT_MIX_CTRL(2),    0x00 },
+       { ADAU1373_DOUT_MIX_CTRL(3),    0x00 },
+       { ADAU1373_DOUT_MIX_CTRL(4),    0x00 },
+       { ADAU1373_DAI_PBL_VOL(0),      0x00 },
+       { ADAU1373_DAI_PBR_VOL(0),      0x00 },
+       { ADAU1373_DAI_PBL_VOL(1),      0x00 },
+       { ADAU1373_DAI_PBR_VOL(1),      0x00 },
+       { ADAU1373_DAI_PBL_VOL(2),      0x00 },
+       { ADAU1373_DAI_PBR_VOL(2),      0x00 },
+       { ADAU1373_DAI_RECL_VOL(0),     0x00 },
+       { ADAU1373_DAI_RECR_VOL(0),     0x00 },
+       { ADAU1373_DAI_RECL_VOL(1),     0x00 },
+       { ADAU1373_DAI_RECR_VOL(1),     0x00 },
+       { ADAU1373_DAI_RECL_VOL(2),     0x00 },
+       { ADAU1373_DAI_RECR_VOL(2),     0x00 },
+       { ADAU1373_DAC1_PBL_VOL,        0x00 },
+       { ADAU1373_DAC1_PBR_VOL,        0x00 },
+       { ADAU1373_DAC2_PBL_VOL,        0x00 },
+       { ADAU1373_DAC2_PBR_VOL,        0x00 },
+       { ADAU1373_ADC_RECL_VOL,        0x00 },
+       { ADAU1373_ADC_RECR_VOL,        0x00 },
+       { ADAU1373_DMIC_RECL_VOL,       0x00 },
+       { ADAU1373_DMIC_RECR_VOL,       0x00 },
+       { ADAU1373_VOL_GAIN1,           0x00 },
+       { ADAU1373_VOL_GAIN2,           0x00 },
+       { ADAU1373_VOL_GAIN3,           0x00 },
+       { ADAU1373_HPF_CTRL,            0x00 },
+       { ADAU1373_BASS1,               0x00 },
+       { ADAU1373_BASS2,               0x00 },
+       { ADAU1373_DRC(0) + 0x0,        0x78 },
+       { ADAU1373_DRC(0) + 0x1,        0x18 },
+       { ADAU1373_DRC(0) + 0x2,        0x00 },
+       { ADAU1373_DRC(0) + 0x3,        0x00 },
+       { ADAU1373_DRC(0) + 0x4,        0x00 },
+       { ADAU1373_DRC(0) + 0x5,        0xc0 },
+       { ADAU1373_DRC(0) + 0x6,        0x00 },
+       { ADAU1373_DRC(0) + 0x7,        0x00 },
+       { ADAU1373_DRC(0) + 0x8,        0x00 },
+       { ADAU1373_DRC(0) + 0x9,        0xc0 },
+       { ADAU1373_DRC(0) + 0xa,        0x88 },
+       { ADAU1373_DRC(0) + 0xb,        0x7a },
+       { ADAU1373_DRC(0) + 0xc,        0xdf },
+       { ADAU1373_DRC(0) + 0xd,        0x20 },
+       { ADAU1373_DRC(0) + 0xe,        0x00 },
+       { ADAU1373_DRC(0) + 0xf,        0x00 },
+       { ADAU1373_DRC(1) + 0x0,        0x78 },
+       { ADAU1373_DRC(1) + 0x1,        0x18 },
+       { ADAU1373_DRC(1) + 0x2,        0x00 },
+       { ADAU1373_DRC(1) + 0x3,        0x00 },
+       { ADAU1373_DRC(1) + 0x4,        0x00 },
+       { ADAU1373_DRC(1) + 0x5,        0xc0 },
+       { ADAU1373_DRC(1) + 0x6,        0x00 },
+       { ADAU1373_DRC(1) + 0x7,        0x00 },
+       { ADAU1373_DRC(1) + 0x8,        0x00 },
+       { ADAU1373_DRC(1) + 0x9,        0xc0 },
+       { ADAU1373_DRC(1) + 0xa,        0x88 },
+       { ADAU1373_DRC(1) + 0xb,        0x7a },
+       { ADAU1373_DRC(1) + 0xc,        0xdf },
+       { ADAU1373_DRC(1) + 0xd,        0x20 },
+       { ADAU1373_DRC(1) + 0xe,        0x00 },
+       { ADAU1373_DRC(1) + 0xf,        0x00 },
+       { ADAU1373_DRC(2) + 0x0,        0x78 },
+       { ADAU1373_DRC(2) + 0x1,        0x18 },
+       { ADAU1373_DRC(2) + 0x2,        0x00 },
+       { ADAU1373_DRC(2) + 0x3,        0x00 },
+       { ADAU1373_DRC(2) + 0x4,        0x00 },
+       { ADAU1373_DRC(2) + 0x5,        0xc0 },
+       { ADAU1373_DRC(2) + 0x6,        0x00 },
+       { ADAU1373_DRC(2) + 0x7,        0x00 },
+       { ADAU1373_DRC(2) + 0x8,        0x00 },
+       { ADAU1373_DRC(2) + 0x9,        0xc0 },
+       { ADAU1373_DRC(2) + 0xa,        0x88 },
+       { ADAU1373_DRC(2) + 0xb,        0x7a },
+       { ADAU1373_DRC(2) + 0xc,        0xdf },
+       { ADAU1373_DRC(2) + 0xd,        0x20 },
+       { ADAU1373_DRC(2) + 0xe,        0x00 },
+       { ADAU1373_DRC(2) + 0xf,        0x00 },
+       { ADAU1373_3D_CTRL1,            0x00 },
+       { ADAU1373_3D_CTRL2,            0x00 },
+       { ADAU1373_FDSP_SEL1,           0x00 },
+       { ADAU1373_FDSP_SEL2,           0x00 },
+       { ADAU1373_FDSP_SEL2,           0x00 },
+       { ADAU1373_FDSP_SEL4,           0x00 },
+       { ADAU1373_DIGMICCTRL,          0x00 },
+       { ADAU1373_DIGEN,               0x00 },
 };
 
 static const unsigned int adau1373_out_tlv[] = {
@@ -418,6 +553,7 @@ static int adau1373_pll_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_codec *codec = w->codec;
+       struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
        unsigned int pll_id = w->name[3] - '1';
        unsigned int val;
 
@@ -426,7 +562,7 @@ static int adau1373_pll_event(struct snd_soc_dapm_widget *w,
        else
                val = 0;
 
-       snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id),
+       regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id),
                ADAU1373_PLL_CTRL6_PLL_EN, val);
 
        if (SND_SOC_DAPM_EVENT_ON(event))
@@ -938,7 +1074,7 @@ static int adau1373_hw_params(struct snd_pcm_substream *substream,
 
        adau1373_dai->enable_src = (div != 0);
 
-       snd_soc_update_bits(codec, ADAU1373_BCLKDIV(dai->id),
+       regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id),
                ADAU1373_BCLKDIV_SR_MASK | ADAU1373_BCLKDIV_BCLK_MASK,
                (div << 2) | ADAU1373_BCLKDIV_64);
 
@@ -959,7 +1095,7 @@ static int adau1373_hw_params(struct snd_pcm_substream *substream,
                return -EINVAL;
        }
 
-       return snd_soc_update_bits(codec, ADAU1373_DAI(dai->id),
+       return regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id),
                        ADAU1373_DAI_WLEN_MASK, ctrl);
 }
 
@@ -1016,7 +1152,7 @@ static int adau1373_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
                return -EINVAL;
        }
 
-       snd_soc_update_bits(codec, ADAU1373_DAI(dai->id),
+       regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id),
                ~ADAU1373_DAI_WLEN_MASK, ctrl);
 
        return 0;
@@ -1039,7 +1175,7 @@ static int adau1373_set_dai_sysclk(struct snd_soc_dai *dai,
        adau1373_dai->sysclk = freq;
        adau1373_dai->clk_src = clk_id;
 
-       snd_soc_update_bits(dai->codec, ADAU1373_BCLKDIV(dai->id),
+       regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id),
                ADAU1373_BCLKDIV_SOURCE, clk_id << 5);
 
        return 0;
@@ -1120,6 +1256,7 @@ static struct snd_soc_dai_driver adau1373_dai_driver[] = {
 static int adau1373_set_pll(struct snd_soc_codec *codec, int pll_id,
        int source, unsigned int freq_in, unsigned int freq_out)
 {
+       struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
        unsigned int dpll_div = 0;
        unsigned int x, r, n, m, i, j, mode;
 
@@ -1187,36 +1324,36 @@ static int adau1373_set_pll(struct snd_soc_codec *codec, int pll_id,
 
        if (dpll_div) {
                dpll_div = 11 - dpll_div;
-               snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id),
+               regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id),
                        ADAU1373_PLL_CTRL6_DPLL_BYPASS, 0);
        } else {
-               snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id),
+               regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id),
                        ADAU1373_PLL_CTRL6_DPLL_BYPASS,
                        ADAU1373_PLL_CTRL6_DPLL_BYPASS);
        }
 
-       snd_soc_write(codec, ADAU1373_DPLL_CTRL(pll_id),
+       regmap_write(adau1373->regmap, ADAU1373_DPLL_CTRL(pll_id),
                (source << 4) | dpll_div);
-       snd_soc_write(codec, ADAU1373_PLL_CTRL1(pll_id), (m >> 8) & 0xff);
-       snd_soc_write(codec, ADAU1373_PLL_CTRL2(pll_id), m & 0xff);
-       snd_soc_write(codec, ADAU1373_PLL_CTRL3(pll_id), (n >> 8) & 0xff);
-       snd_soc_write(codec, ADAU1373_PLL_CTRL4(pll_id), n & 0xff);
-       snd_soc_write(codec, ADAU1373_PLL_CTRL5(pll_id),
+       regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL1(pll_id), (m >> 8) & 0xff);
+       regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL2(pll_id), m & 0xff);
+       regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL3(pll_id), (n >> 8) & 0xff);
+       regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL4(pll_id), n & 0xff);
+       regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL5(pll_id),
                (r << 3) | (x << 1) | mode);
 
        /* Set sysclk to pll_rate / 4 */
-       snd_soc_update_bits(codec, ADAU1373_CLK_SRC_DIV(pll_id), 0x3f, 0x09);
+       regmap_update_bits(adau1373->regmap, ADAU1373_CLK_SRC_DIV(pll_id), 0x3f, 0x09);
 
        return 0;
 }
 
-static void adau1373_load_drc_settings(struct snd_soc_codec *codec,
+static void adau1373_load_drc_settings(struct adau1373 *adau1373,
        unsigned int nr, uint8_t *drc)
 {
        unsigned int i;
 
        for (i = 0; i < ADAU1373_DRC_SIZE; ++i)
-               snd_soc_write(codec, ADAU1373_DRC(nr) + i, drc[i]);
+               regmap_write(adau1373->regmap, ADAU1373_DRC(nr) + i, drc[i]);
 }
 
 static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias)
@@ -1235,13 +1372,14 @@ static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias)
 
 static int adau1373_probe(struct snd_soc_codec *codec)
 {
+       struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
        struct adau1373_platform_data *pdata = codec->dev->platform_data;
        bool lineout_differential = false;
        unsigned int val;
        int ret;
        int i;
 
-       ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
+       ret = snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
        if (ret) {
                dev_err(codec->dev, "failed to set cache I/O: %d\n", ret);
                return ret;
@@ -1256,7 +1394,7 @@ static int adau1373_probe(struct snd_soc_codec *codec)
                        return -EINVAL;
 
                for (i = 0; i < pdata->num_drc; ++i) {
-                       adau1373_load_drc_settings(codec, i,
+                       adau1373_load_drc_settings(adau1373, i,
                                pdata->drc_setting[i]);
                }
 
@@ -1268,18 +1406,18 @@ static int adau1373_probe(struct snd_soc_codec *codec)
                        if (pdata->input_differential[i])
                                val |= BIT(i);
                }
-               snd_soc_write(codec, ADAU1373_INPUT_MODE, val);
+               regmap_write(adau1373->regmap, ADAU1373_INPUT_MODE, val);
 
                val = 0;
                if (pdata->lineout_differential)
                        val |= ADAU1373_OUTPUT_CTRL_LDIFF;
                if (pdata->lineout_ground_sense)
                        val |= ADAU1373_OUTPUT_CTRL_LNFBEN;
-               snd_soc_write(codec, ADAU1373_OUTPUT_CTRL, val);
+               regmap_write(adau1373->regmap, ADAU1373_OUTPUT_CTRL, val);
 
                lineout_differential = pdata->lineout_differential;
 
-               snd_soc_write(codec, ADAU1373_EP_CTRL,
+               regmap_write(adau1373->regmap, ADAU1373_EP_CTRL,
                        (pdata->micbias1 << ADAU1373_EP_CTRL_MICBIAS1_OFFSET) |
                        (pdata->micbias2 << ADAU1373_EP_CTRL_MICBIAS2_OFFSET));
        }
@@ -1289,7 +1427,7 @@ static int adau1373_probe(struct snd_soc_codec *codec)
                        ARRAY_SIZE(adau1373_lineout2_controls));
        }
 
-       snd_soc_write(codec, ADAU1373_ADC_CTRL,
+       regmap_write(adau1373->regmap, ADAU1373_ADC_CTRL,
            ADAU1373_ADC_CTRL_RESET_FORCE | ADAU1373_ADC_CTRL_PEAK_DETECT);
 
        return 0;
@@ -1298,17 +1436,19 @@ static int adau1373_probe(struct snd_soc_codec *codec)
 static int adau1373_set_bias_level(struct snd_soc_codec *codec,
        enum snd_soc_bias_level level)
 {
+       struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
+
        switch (level) {
        case SND_SOC_BIAS_ON:
                break;
        case SND_SOC_BIAS_PREPARE:
                break;
        case SND_SOC_BIAS_STANDBY:
-               snd_soc_update_bits(codec, ADAU1373_PWDN_CTRL3,
+               regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3,
                        ADAU1373_PWDN_CTRL3_PWR_EN, ADAU1373_PWDN_CTRL3_PWR_EN);
                break;
        case SND_SOC_BIAS_OFF:
-               snd_soc_update_bits(codec, ADAU1373_PWDN_CTRL3,
+               regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3,
                        ADAU1373_PWDN_CTRL3_PWR_EN, 0);
                break;
        }
@@ -1324,17 +1464,49 @@ static int adau1373_remove(struct snd_soc_codec *codec)
 
 static int adau1373_suspend(struct snd_soc_codec *codec)
 {
-       return adau1373_set_bias_level(codec, SND_SOC_BIAS_OFF);
+       struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
+       int ret;
+
+       ret = adau1373_set_bias_level(codec, SND_SOC_BIAS_OFF);
+       regcache_cache_only(adau1373->regmap, true);
+
+       return ret;
 }
 
 static int adau1373_resume(struct snd_soc_codec *codec)
 {
+       struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
+
+       regcache_cache_only(adau1373->regmap, false);
        adau1373_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-       snd_soc_cache_sync(codec);
+       regcache_sync(adau1373->regmap);
 
        return 0;
 }
 
+static bool adau1373_register_volatile(struct device *dev, unsigned int reg)
+{
+       switch (reg) {
+       case ADAU1373_SOFT_RESET:
+       case ADAU1373_ADC_DAC_STATUS:
+               return true;
+       default:
+               return false;
+       }
+}
+
+static const struct regmap_config adau1373_regmap_config = {
+       .val_bits = 8,
+       .reg_bits = 8,
+
+       .volatile_reg = adau1373_register_volatile,
+       .max_register = ADAU1373_SOFT_RESET,
+
+       .cache_type = REGCACHE_RBTREE,
+       .reg_defaults = adau1373_reg_defaults,
+       .num_reg_defaults = ARRAY_SIZE(adau1373_reg_defaults),
+};
+
 static struct snd_soc_codec_driver adau1373_codec_driver = {
        .probe =        adau1373_probe,
        .remove =       adau1373_remove,
@@ -1342,9 +1514,6 @@ static struct snd_soc_codec_driver adau1373_codec_driver = {
        .resume =       adau1373_resume,
        .set_bias_level = adau1373_set_bias_level,
        .idle_bias_off = true,
-       .reg_cache_size = ARRAY_SIZE(adau1373_default_regs),
-       .reg_cache_default = adau1373_default_regs,
-       .reg_word_size = sizeof(uint8_t),
 
        .set_pll = adau1373_set_pll,
 
@@ -1366,6 +1535,13 @@ static int adau1373_i2c_probe(struct i2c_client *client,
        if (!adau1373)
                return -ENOMEM;
 
+       adau1373->regmap = devm_regmap_init_i2c(client,
+               &adau1373_regmap_config);
+       if (IS_ERR(adau1373->regmap))
+               return PTR_ERR(adau1373->regmap);
+
+       regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00);
+
        dev_set_drvdata(&client->dev, adau1373);
 
        ret = snd_soc_register_codec(&client->dev, &adau1373_codec_driver,
index 15b012d0f226c48a4178b1c9f4d10468708dcd1d..14a7c169d004ebf97fabbbccfd8df0434327c639 100644 (file)
 
 #define ADAV80X_PLL_OUTE_SYSCLKPD(x)           BIT(2 - (x))
 
-static u8 adav80x_default_regs[] = {
-       0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x01, 0x80, 0x26, 0x00, 0x00,
-       0x02, 0x40, 0x20, 0x00, 0x09, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0x92, 0xb1, 0x37,
-       0x48, 0xd2, 0xfb, 0xca, 0xd2, 0x15, 0xe8, 0x29, 0xb9, 0x6a, 0xda, 0x2b,
-       0xb7, 0xc0, 0x11, 0x65, 0x5c, 0xf6, 0xff, 0x8d, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00,
-       0x00, 0xe8, 0x46, 0xe1, 0x5b, 0xd3, 0x43, 0x77, 0x93, 0xa7, 0x44, 0xee,
-       0x32, 0x12, 0xc0, 0x11, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x3f,
-       0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x52, 0x00,
+static struct reg_default adav80x_reg_defaults[] = {
+       { ADAV80X_PLAYBACK_CTRL,        0x01 },
+       { ADAV80X_AUX_IN_CTRL,          0x01 },
+       { ADAV80X_REC_CTRL,             0x02 },
+       { ADAV80X_AUX_OUT_CTRL,         0x01 },
+       { ADAV80X_DPATH_CTRL1,          0xc0 },
+       { ADAV80X_DPATH_CTRL2,          0x11 },
+       { ADAV80X_DAC_CTRL1,            0x00 },
+       { ADAV80X_DAC_CTRL2,            0x00 },
+       { ADAV80X_DAC_CTRL3,            0x00 },
+       { ADAV80X_DAC_L_VOL,            0xff },
+       { ADAV80X_DAC_R_VOL,            0xff },
+       { ADAV80X_PGA_L_VOL,            0x00 },
+       { ADAV80X_PGA_R_VOL,            0x00 },
+       { ADAV80X_ADC_CTRL1,            0x00 },
+       { ADAV80X_ADC_CTRL2,            0x00 },
+       { ADAV80X_ADC_L_VOL,            0xff },
+       { ADAV80X_ADC_R_VOL,            0xff },
+       { ADAV80X_PLL_CTRL1,            0x00 },
+       { ADAV80X_PLL_CTRL2,            0x00 },
+       { ADAV80X_ICLK_CTRL1,           0x00 },
+       { ADAV80X_ICLK_CTRL2,           0x00 },
+       { ADAV80X_PLL_CLK_SRC,          0x00 },
+       { ADAV80X_PLL_OUTE,             0x00 },
 };
 
 struct adav80x {
-       enum snd_soc_control_type control_type;
+       struct regmap *regmap;
 
        enum adav80x_clk_src clk_src;
        unsigned int sysclk;
@@ -298,7 +310,7 @@ static int adav80x_set_deemph(struct snd_soc_codec *codec)
                val = ADAV80X_DAC_CTRL2_DEEMPH_NONE;
        }
 
-       return snd_soc_update_bits(codec, ADAV80X_DAC_CTRL2,
+       return regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL2,
                ADAV80X_DAC_CTRL2_DEEMPH_MASK, val);
 }
 
@@ -394,10 +406,11 @@ static int adav80x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
                return -EINVAL;
        }
 
-       snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][0],
+       regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][0],
                ADAV80X_CAPTURE_MODE_MASK | ADAV80X_CAPTURE_MODE_MASTER,
                capture);
-       snd_soc_write(codec, adav80x_port_ctrl_regs[dai->id][1], playback);
+       regmap_write(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][1],
+               playback);
 
        adav80x->dai_fmt[dai->id] = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
 
@@ -407,6 +420,7 @@ static int adav80x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 static int adav80x_set_adc_clock(struct snd_soc_codec *codec,
                unsigned int sample_rate)
 {
+       struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
        unsigned int val;
 
        if (sample_rate <= 48000)
@@ -414,7 +428,7 @@ static int adav80x_set_adc_clock(struct snd_soc_codec *codec,
        else
                val = ADAV80X_ADC_CTRL1_MODULATOR_64FS;
 
-       snd_soc_update_bits(codec, ADAV80X_ADC_CTRL1,
+       regmap_update_bits(adav80x->regmap, ADAV80X_ADC_CTRL1,
                ADAV80X_ADC_CTRL1_MODULATOR_MASK, val);
 
        return 0;
@@ -423,6 +437,7 @@ static int adav80x_set_adc_clock(struct snd_soc_codec *codec,
 static int adav80x_set_dac_clock(struct snd_soc_codec *codec,
                unsigned int sample_rate)
 {
+       struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
        unsigned int val;
 
        if (sample_rate <= 48000)
@@ -430,7 +445,7 @@ static int adav80x_set_dac_clock(struct snd_soc_codec *codec,
        else
                val = ADAV80X_DAC_CTRL2_DIV2 | ADAV80X_DAC_CTRL2_INTERPOL_128FS;
 
-       snd_soc_update_bits(codec, ADAV80X_DAC_CTRL2,
+       regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL2,
                ADAV80X_DAC_CTRL2_DIV_MASK | ADAV80X_DAC_CTRL2_INTERPOL_MASK,
                val);
 
@@ -440,6 +455,7 @@ static int adav80x_set_dac_clock(struct snd_soc_codec *codec,
 static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec,
                struct snd_soc_dai *dai, snd_pcm_format_t format)
 {
+       struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
        unsigned int val;
 
        switch (format) {
@@ -459,7 +475,7 @@ static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec,
                return -EINVAL;
        }
 
-       snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][0],
+       regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][0],
                ADAV80X_CAPTURE_WORD_LEN_MASK, val);
 
        return 0;
@@ -491,7 +507,7 @@ static int adav80x_set_playback_pcm_format(struct snd_soc_codec *codec,
                return -EINVAL;
        }
 
-       snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][1],
+       regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][1],
                ADAV80X_PLAYBACK_MODE_MASK, val);
 
        return 0;
@@ -554,8 +570,10 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec,
                                        ADAV80X_ICLK_CTRL1_ICLK2_SRC(clk_id);
                        iclk_ctrl2 = ADAV80X_ICLK_CTRL2_ICLK1_SRC(clk_id);
 
-                       snd_soc_write(codec, ADAV80X_ICLK_CTRL1, iclk_ctrl1);
-                       snd_soc_write(codec, ADAV80X_ICLK_CTRL2, iclk_ctrl2);
+                       regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL1,
+                               iclk_ctrl1);
+                       regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL2,
+                               iclk_ctrl2);
 
                        snd_soc_dapm_sync(&codec->dapm);
                }
@@ -575,10 +593,12 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec,
                mask = ADAV80X_PLL_OUTE_SYSCLKPD(clk_id);
 
                if (freq == 0) {
-                       snd_soc_update_bits(codec, ADAV80X_PLL_OUTE, mask, mask);
+                       regmap_update_bits(adav80x->regmap, ADAV80X_PLL_OUTE,
+                               mask, mask);
                        adav80x->sysclk_pd[clk_id] = true;
                } else {
-                       snd_soc_update_bits(codec, ADAV80X_PLL_OUTE, mask, 0);
+                       regmap_update_bits(adav80x->regmap, ADAV80X_PLL_OUTE,
+                               mask, 0);
                        adav80x->sysclk_pd[clk_id] = false;
                }
 
@@ -650,9 +670,9 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id,
                return -EINVAL;
        }
 
-       snd_soc_update_bits(codec, ADAV80X_PLL_CTRL1, ADAV80X_PLL_CTRL1_PLLDIV,
-               pll_ctrl1);
-       snd_soc_update_bits(codec, ADAV80X_PLL_CTRL2,
+       regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CTRL1,
+                       ADAV80X_PLL_CTRL1_PLLDIV, pll_ctrl1);
+       regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CTRL2,
                        ADAV80X_PLL_CTRL2_PLL_MASK(pll_id), pll_ctrl2);
 
        if (source != adav80x->pll_src) {
@@ -661,7 +681,7 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id,
                else
                        pll_src = ADAV80X_PLL_CLK_SRC_PLL_XIN(pll_id);
 
-               snd_soc_update_bits(codec, ADAV80X_PLL_CLK_SRC,
+               regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CLK_SRC,
                                ADAV80X_PLL_CLK_SRC_PLL_MASK(pll_id), pll_src);
 
                adav80x->pll_src = source;
@@ -675,6 +695,7 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id,
 static int adav80x_set_bias_level(struct snd_soc_codec *codec,
                enum snd_soc_bias_level level)
 {
+       struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
        unsigned int mask = ADAV80X_DAC_CTRL1_PD;
 
        switch (level) {
@@ -683,10 +704,12 @@ static int adav80x_set_bias_level(struct snd_soc_codec *codec,
        case SND_SOC_BIAS_PREPARE:
                break;
        case SND_SOC_BIAS_STANDBY:
-               snd_soc_update_bits(codec, ADAV80X_DAC_CTRL1, mask, 0x00);
+               regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL1, mask,
+                       0x00);
                break;
        case SND_SOC_BIAS_OFF:
-               snd_soc_update_bits(codec, ADAV80X_DAC_CTRL1, mask, mask);
+               regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL1, mask,
+                       mask);
                break;
        }
 
@@ -780,7 +803,7 @@ static int adav80x_probe(struct snd_soc_codec *codec)
        int ret;
        struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
 
-       ret = snd_soc_codec_set_cache_io(codec, 7, 9, adav80x->control_type);
+       ret = snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
        if (ret) {
                dev_err(codec->dev, "failed to set cache I/O: %d\n", ret);
                return ret;
@@ -791,23 +814,31 @@ static int adav80x_probe(struct snd_soc_codec *codec)
        snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL2");
 
        /* Power down S/PDIF receiver, since it is currently not supported */
-       snd_soc_write(codec, ADAV80X_PLL_OUTE, 0x20);
+       regmap_write(adav80x->regmap, ADAV80X_PLL_OUTE, 0x20);
        /* Disable DAC zero flag */
-       snd_soc_write(codec, ADAV80X_DAC_CTRL3, 0x6);
+       regmap_write(adav80x->regmap, ADAV80X_DAC_CTRL3, 0x6);
 
        return adav80x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 }
 
 static int adav80x_suspend(struct snd_soc_codec *codec)
 {
-       return adav80x_set_bias_level(codec, SND_SOC_BIAS_OFF);
+       struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
+       int ret;
+
+       ret = adav80x_set_bias_level(codec, SND_SOC_BIAS_OFF);
+       regcache_cache_only(adav80x->regmap, true);
+
+       return ret;
 }
 
 static int adav80x_resume(struct snd_soc_codec *codec)
 {
+       struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
+
+       regcache_cache_only(adav80x->regmap, false);
        adav80x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-       codec->cache_sync = 1;
-       snd_soc_cache_sync(codec);
+       regcache_sync(adav80x->regmap);
 
        return 0;
 }
@@ -827,10 +858,6 @@ static struct snd_soc_codec_driver adav80x_codec_driver = {
        .set_pll = adav80x_set_pll,
        .set_sysclk = adav80x_set_sysclk,
 
-       .reg_word_size = sizeof(u8),
-       .reg_cache_size = ARRAY_SIZE(adav80x_default_regs),
-       .reg_cache_default = adav80x_default_regs,
-
        .controls = adav80x_controls,
        .num_controls = ARRAY_SIZE(adav80x_controls),
        .dapm_widgets = adav80x_dapm_widgets,
@@ -839,18 +866,21 @@ static struct snd_soc_codec_driver adav80x_codec_driver = {
        .num_dapm_routes = ARRAY_SIZE(adav80x_dapm_routes),
 };
 
-static int adav80x_bus_probe(struct device *dev,
-                            enum snd_soc_control_type control_type)
+static int adav80x_bus_probe(struct device *dev, struct regmap *regmap)
 {
        struct adav80x *adav80x;
        int ret;
 
+       if (IS_ERR(regmap))
+               return PTR_ERR(regmap);
+
        adav80x = kzalloc(sizeof(*adav80x), GFP_KERNEL);
        if (!adav80x)
                return -ENOMEM;
 
+
        dev_set_drvdata(dev, adav80x);
-       adav80x->control_type = control_type;
+       adav80x->regmap = regmap;
 
        ret = snd_soc_register_codec(dev, &adav80x_codec_driver,
                adav80x_dais, ARRAY_SIZE(adav80x_dais));
@@ -868,6 +898,19 @@ static int adav80x_bus_remove(struct device *dev)
 }
 
 #if defined(CONFIG_SPI_MASTER)
+static const struct regmap_config adav80x_spi_regmap_config = {
+       .val_bits = 8,
+       .pad_bits = 1,
+       .reg_bits = 7,
+       .read_flag_mask = 0x01,
+
+       .max_register = ADAV80X_PLL_OUTE,
+
+       .cache_type = REGCACHE_RBTREE,
+       .reg_defaults = adav80x_reg_defaults,
+       .num_reg_defaults = ARRAY_SIZE(adav80x_reg_defaults),
+};
+
 static const struct spi_device_id adav80x_spi_id[] = {
        { "adav801", 0 },
        { }
@@ -876,7 +919,8 @@ MODULE_DEVICE_TABLE(spi, adav80x_spi_id);
 
 static int adav80x_spi_probe(struct spi_device *spi)
 {
-       return adav80x_bus_probe(&spi->dev, SND_SOC_SPI);
+       return adav80x_bus_probe(&spi->dev,
+               devm_regmap_init_spi(spi, &adav80x_spi_regmap_config));
 }
 
 static int adav80x_spi_remove(struct spi_device *spi)
@@ -896,6 +940,18 @@ static struct spi_driver adav80x_spi_driver = {
 #endif
 
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+static const struct regmap_config adav80x_i2c_regmap_config = {
+       .val_bits = 8,
+       .pad_bits = 1,
+       .reg_bits = 7,
+
+       .max_register = ADAV80X_PLL_OUTE,
+
+       .cache_type = REGCACHE_RBTREE,
+       .reg_defaults = adav80x_reg_defaults,
+       .num_reg_defaults = ARRAY_SIZE(adav80x_reg_defaults),
+};
+
 static const struct i2c_device_id adav80x_i2c_id[] = {
        { "adav803", 0 },
        { }
@@ -905,7 +961,8 @@ MODULE_DEVICE_TABLE(i2c, adav80x_i2c_id);
 static int adav80x_i2c_probe(struct i2c_client *client,
                             const struct i2c_device_id *id)
 {
-       return adav80x_bus_probe(&client->dev, SND_SOC_I2C);
+       return adav80x_bus_probe(&client->dev,
+               devm_regmap_init_i2c(client, &adav80x_i2c_regmap_config));
 }
 
 static int adav80x_i2c_remove(struct i2c_client *client)
index 71059c07ae7be5abc3a9c70fd5443bce27493ced..b4819dcd4f4dc73f781383681d0ed4198ac2f220 100644 (file)
@@ -45,8 +45,6 @@
 #define AK4104_TX_TXE                  (1 << 0)
 #define AK4104_TX_V                    (1 << 1)
 
-#define DRV_NAME "ak4104-codec"
-
 struct ak4104_private {
        struct regmap *regmap;
 };
@@ -291,12 +289,19 @@ static const struct of_device_id ak4104_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ak4104_of_match);
 
+static const struct spi_device_id ak4104_id_table[] = {
+       { "ak4104", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(spi, ak4104_id_table);
+
 static struct spi_driver ak4104_spi_driver = {
        .driver  = {
-               .name   = DRV_NAME,
+               .name   = "ak4104",
                .owner  = THIS_MODULE,
                .of_match_table = ak4104_of_match,
        },
+       .id_table = ak4104_id_table,
        .probe  = ak4104_spi_probe,
        .remove = ak4104_spi_remove,
 };
index 5f9af1fb76e862a1fb2eb4e73176d47cccf4aef8..49cc5f6d6dba41cd1d45712fc15037d8031ddaf5 100644 (file)
@@ -328,7 +328,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream,
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                ak4641->playback_fs = rate;
                ak4641_set_deemph(codec);
-       };
+       }
 
        return 0;
 }
index 2d037870970221b2c2a87f4f96cac4886d606cb9..21c35ed778cccfcc38c250ffb1e6663eb25fba68 100644 (file)
@@ -352,7 +352,6 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
         */
        default:
                return -EINVAL;
-               break;
        }
        snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data);
 
@@ -405,7 +404,6 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream,
                break;
        default:
                return -EINVAL;
-               break;
        }
        snd_soc_update_bits(codec, MD_CTL2, FS_MASK, rate);
 
index 657808ba1418d5588e961081c5e1578cbb671400..6f05b17d19657aebb15f5793ec3cb36b07c57422 100644 (file)
@@ -1477,21 +1477,25 @@ static void arizona_enable_fll(struct arizona_fll *fll,
 {
        struct arizona *arizona = fll->arizona;
        int ret;
+       bool use_sync = false;
 
        /*
         * If we have both REFCLK and SYNCCLK then enable both,
         * otherwise apply the SYNCCLK settings to REFCLK.
         */
-       if (fll->ref_src >= 0 && fll->ref_src != fll->sync_src) {
+       if (fll->ref_src >= 0 && fll->ref_freq &&
+           fll->ref_src != fll->sync_src) {
                regmap_update_bits(arizona->regmap, fll->base + 5,
                                   ARIZONA_FLL1_OUTDIV_MASK,
                                   ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT);
 
                arizona_apply_fll(arizona, fll->base, ref, fll->ref_src,
                                  false);
-               if (fll->sync_src >= 0)
+               if (fll->sync_src >= 0) {
                        arizona_apply_fll(arizona, fll->base + 0x10, sync,
                                          fll->sync_src, true);
+                       use_sync = true;
+               }
        } else if (fll->sync_src >= 0) {
                regmap_update_bits(arizona->regmap, fll->base + 5,
                                   ARIZONA_FLL1_OUTDIV_MASK,
@@ -1511,7 +1515,7 @@ static void arizona_enable_fll(struct arizona_fll *fll,
         * Increase the bandwidth if we're not using a low frequency
         * sync source.
         */
-       if (fll->sync_src >= 0 && fll->sync_freq > 100000)
+       if (use_sync && fll->sync_freq > 100000)
                regmap_update_bits(arizona->regmap, fll->base + 0x17,
                                   ARIZONA_FLL1_SYNC_BW, 0);
        else
@@ -1526,8 +1530,7 @@ static void arizona_enable_fll(struct arizona_fll *fll,
 
        regmap_update_bits(arizona->regmap, fll->base + 1,
                           ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
-       if (fll->ref_src >= 0 && fll->sync_src >= 0 &&
-           fll->ref_src != fll->sync_src)
+       if (use_sync)
                regmap_update_bits(arizona->regmap, fll->base + 0x11,
                                   ARIZONA_FLL1_SYNC_ENA,
                                   ARIZONA_FLL1_SYNC_ENA);
@@ -1561,10 +1564,12 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
        if (fll->ref_src == source && fll->ref_freq == Fref)
                return 0;
 
-       if (fll->fout && Fref > 0) {
-               ret = arizona_calc_fll(fll, &ref, Fref, fll->fout);
-               if (ret != 0)
-                       return ret;
+       if (fll->fout) {
+               if (Fref > 0) {
+                       ret = arizona_calc_fll(fll, &ref, Fref, fll->fout);
+                       if (ret != 0)
+                               return ret;
+               }
 
                if (fll->sync_src >= 0) {
                        ret = arizona_calc_fll(fll, &sync, fll->sync_freq,
index 23316c887b19211f7c7473767b956895abda397f..43737a27d79caff3dda074565d0201493d4fb96e 100644 (file)
 #include <sound/soc.h>
 #include <sound/initval.h>
 
-static inline unsigned int cq93vc_read(struct snd_soc_codec *codec,
-                                               unsigned int reg)
-{
-       struct davinci_vc *davinci_vc = codec->control_data;
-
-       return readl(davinci_vc->base + reg);
-}
-
-static inline int cq93vc_write(struct snd_soc_codec *codec, unsigned int reg,
-                      unsigned int value)
-{
-       struct davinci_vc *davinci_vc = codec->control_data;
-
-       writel(value, davinci_vc->base + reg);
-
-       return 0;
-}
-
 static const struct snd_kcontrol_new cq93vc_snd_controls[] = {
        SOC_SINGLE("PGA Capture Volume", DAVINCI_VC_REG05, 0, 0x03, 0),
        SOC_SINGLE("Mono DAC Playback Volume", DAVINCI_VC_REG09, 0, 0x3f, 0),
@@ -64,13 +46,15 @@ static const struct snd_kcontrol_new cq93vc_snd_controls[] = {
 static int cq93vc_mute(struct snd_soc_dai *dai, int mute)
 {
        struct snd_soc_codec *codec = dai->codec;
-       u8 reg = cq93vc_read(codec, DAVINCI_VC_REG09) & ~DAVINCI_VC_REG09_MUTE;
+       u8 reg;
 
        if (mute)
-               cq93vc_write(codec, DAVINCI_VC_REG09,
-                            reg | DAVINCI_VC_REG09_MUTE);
+               reg = DAVINCI_VC_REG09_MUTE;
        else
-               cq93vc_write(codec, DAVINCI_VC_REG09, reg);
+               reg = 0;
+
+       snd_soc_update_bits(codec, DAVINCI_VC_REG09, DAVINCI_VC_REG09_MUTE,
+                           reg);
 
        return 0;
 }
@@ -79,7 +63,7 @@ static int cq93vc_set_dai_sysclk(struct snd_soc_dai *codec_dai,
                                 int clk_id, unsigned int freq, int dir)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
-       struct davinci_vc *davinci_vc = codec->control_data;
+       struct davinci_vc *davinci_vc = codec->dev->platform_data;
 
        switch (freq) {
        case 22579200:
@@ -97,18 +81,18 @@ static int cq93vc_set_bias_level(struct snd_soc_codec *codec,
 {
        switch (level) {
        case SND_SOC_BIAS_ON:
-               cq93vc_write(codec, DAVINCI_VC_REG12,
+               snd_soc_write(codec, DAVINCI_VC_REG12,
                             DAVINCI_VC_REG12_POWER_ALL_ON);
                break;
        case SND_SOC_BIAS_PREPARE:
                break;
        case SND_SOC_BIAS_STANDBY:
-               cq93vc_write(codec, DAVINCI_VC_REG12,
+               snd_soc_write(codec, DAVINCI_VC_REG12,
                             DAVINCI_VC_REG12_POWER_ALL_OFF);
                break;
        case SND_SOC_BIAS_OFF:
                /* force all power off */
-               cq93vc_write(codec, DAVINCI_VC_REG12,
+               snd_soc_write(codec, DAVINCI_VC_REG12,
                             DAVINCI_VC_REG12_POWER_ALL_OFF);
                break;
        }
@@ -154,11 +138,9 @@ static int cq93vc_probe(struct snd_soc_codec *codec)
        struct davinci_vc *davinci_vc = codec->dev->platform_data;
 
        davinci_vc->cq93vc.codec = codec;
-       codec->control_data = davinci_vc;
+       codec->control_data = davinci_vc->regmap;
 
-       /* Set controls */
-       snd_soc_add_codec_controls(codec, cq93vc_snd_controls,
-                            ARRAY_SIZE(cq93vc_snd_controls));
+       snd_soc_codec_set_cache_io(codec, 32, 32, SND_SOC_REGMAP);
 
        /* Off, with power on */
        cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
@@ -174,12 +156,12 @@ static int cq93vc_remove(struct snd_soc_codec *codec)
 }
 
 static struct snd_soc_codec_driver soc_codec_dev_cq93vc = {
-       .read = cq93vc_read,
-       .write = cq93vc_write,
        .set_bias_level = cq93vc_set_bias_level,
        .probe = cq93vc_probe,
        .remove = cq93vc_remove,
        .resume = cq93vc_resume,
+       .controls = cq93vc_snd_controls,
+       .num_controls = ARRAY_SIZE(cq93vc_snd_controls),
 };
 
 static int cq93vc_platform_probe(struct platform_device *pdev)
index a20f1bb8f0715011dad1a710cf038a80121e30b9..f6e953454bc0856ffccb87ec6680a670d3e90cbd 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/gpio.h>
 #include <linux/i2c.h>
 #include <linux/spi/spi.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <sound/pcm.h>
index 3b20c86cdb01671c283cec22b58aa6fac5acddcd..549d5d6a3fef47f0680934c68b36a2c6a48529d0 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/of_gpio.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/regmap.h>
@@ -28,6 +29,7 @@
 #include <sound/soc-dapm.h>
 #include <sound/initval.h>
 #include <sound/tlv.h>
+#include <sound/cs42l73.h>
 #include "cs42l73.h"
 
 struct sp_config {
@@ -35,6 +37,7 @@ struct sp_config {
        u32 srate;
 };
 struct  cs42l73_private {
+       struct cs42l73_platform_data pdata;
        struct sp_config config[3];
        struct regmap *regmap;
        u32 sysclk;
@@ -310,15 +313,6 @@ static const struct soc_enum ng_delay_enum =
        SOC_ENUM_SINGLE(CS42L73_NGCAB, 0,
                ARRAY_SIZE(cs42l73_ng_delay_text), cs42l73_ng_delay_text);
 
-static const char * const charge_pump_freq_text[] = {
-       "0", "1", "2", "3", "4",
-       "5", "6", "7", "8", "9",
-       "10", "11", "12", "13", "14", "15" };
-
-static const struct soc_enum charge_pump_enum =
-       SOC_ENUM_SINGLE(CS42L73_CPFCHC, 4,
-               ARRAY_SIZE(charge_pump_freq_text), charge_pump_freq_text);
-
 static const char * const cs42l73_mono_mix_texts[] = {
        "Left", "Right", "Mono Mix"};
 
@@ -511,8 +505,6 @@ static const struct snd_kcontrol_new cs42l73_snd_controls[] = {
        SOC_SINGLE("NG Threshold", CS42L73_NGCAB, 2, 7, 0),
        SOC_ENUM("NG Delay", ng_delay_enum),
 
-       SOC_ENUM("Charge Pump Frequency", charge_pump_enum),
-
        SOC_DOUBLE_R_TLV("XSP-IP Volume",
                        CS42L73_XSPAIPAA, CS42L73_XSPBIPBA, 0, 0x3F, 1,
                        attn_tlv),
@@ -1055,11 +1047,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 
        switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
        case SND_SOC_DAIFMT_CBM_CFM:
-               mmcc |= MS_MASTER;
+               mmcc |= CS42L73_MS_MASTER;
                break;
 
        case SND_SOC_DAIFMT_CBS_CFS:
-               mmcc &= ~MS_MASTER;
+               mmcc &= ~CS42L73_MS_MASTER;
                break;
 
        default:
@@ -1071,11 +1063,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 
        switch (format) {
        case SND_SOC_DAIFMT_I2S:
-               spc &= ~SPDIF_PCM;
+               spc &= ~CS42L73_SPDIF_PCM;
                break;
        case SND_SOC_DAIFMT_DSP_A:
        case SND_SOC_DAIFMT_DSP_B:
-               if (mmcc & MS_MASTER) {
+               if (mmcc & CS42L73_MS_MASTER) {
                        dev_err(codec->dev,
                                "PCM format in slave mode only\n");
                        return -EINVAL;
@@ -1085,25 +1077,25 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
                                "PCM format is not supported on ASP port\n");
                        return -EINVAL;
                }
-               spc |= SPDIF_PCM;
+               spc |= CS42L73_SPDIF_PCM;
                break;
        default:
                return -EINVAL;
        }
 
-       if (spc & SPDIF_PCM) {
+       if (spc & CS42L73_SPDIF_PCM) {
                /* Clear PCM mode, clear PCM_BIT_ORDER bit for MSB->LSB */
-               spc &= ~(PCM_MODE_MASK | PCM_BIT_ORDER);
+               spc &= ~(CS42L73_PCM_MODE_MASK | CS42L73_PCM_BIT_ORDER);
                switch (format) {
                case SND_SOC_DAIFMT_DSP_B:
                        if (inv == SND_SOC_DAIFMT_IB_IF)
-                               spc |= PCM_MODE0;
+                               spc |= CS42L73_PCM_MODE0;
                        if (inv == SND_SOC_DAIFMT_IB_NF)
-                               spc |= PCM_MODE1;
+                               spc |= CS42L73_PCM_MODE1;
                break;
                case SND_SOC_DAIFMT_DSP_A:
                        if (inv == SND_SOC_DAIFMT_IB_IF)
-                               spc |= PCM_MODE1;
+                               spc |= CS42L73_PCM_MODE1;
                        break;
                default:
                        return -EINVAL;
@@ -1163,7 +1155,7 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream,
        int mclk_coeff;
        int srate = params_rate(params);
 
-       if (priv->config[id].mmcc & MS_MASTER) {
+       if (priv->config[id].mmcc & CS42L73_MS_MASTER) {
                /* CS42L73 Master */
                /* MCLK -> srate */
                mclk_coeff =
@@ -1182,13 +1174,13 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream,
                priv->config[id].spc &= 0xFC;
                /* Use SCLK=64*Fs if internal MCLK >= 6.4MHz */
                if (priv->mclk >= 6400000)
-                       priv->config[id].spc |= MCK_SCLK_64FS;
+                       priv->config[id].spc |= CS42L73_MCK_SCLK_64FS;
                else
-                       priv->config[id].spc |= MCK_SCLK_MCLK;
+                       priv->config[id].spc |= CS42L73_MCK_SCLK_MCLK;
        } else {
                /* CS42L73 Slave */
                priv->config[id].spc &= 0xFC;
-               priv->config[id].spc |= MCK_SCLK_64FS;
+               priv->config[id].spc |= CS42L73_MCK_SCLK_64FS;
        }
        /* Update ASRCs */
        priv->config[id].srate = srate;
@@ -1208,8 +1200,8 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
 
        switch (level) {
        case SND_SOC_BIAS_ON:
-               snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 0);
-               snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 0);
+               snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 0);
+               snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 0);
                break;
 
        case SND_SOC_BIAS_PREPARE:
@@ -1220,11 +1212,11 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
                        regcache_cache_only(cs42l73->regmap, false);
                        regcache_sync(cs42l73->regmap);
                }
-               snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1);
+               snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1);
                break;
 
        case SND_SOC_BIAS_OFF:
-               snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1);
+               snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1);
                if (cs42l73->shutdwn_delay > 0) {
                        mdelay(cs42l73->shutdwn_delay);
                        cs42l73->shutdwn_delay = 0;
@@ -1233,7 +1225,7 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
                                     * down.
                                     */
                }
-               snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 1);
+               snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 1);
                break;
        }
        codec->dapm.bias_level = level;
@@ -1367,11 +1359,16 @@ static int cs42l73_probe(struct snd_soc_codec *codec)
                return ret;
        }
 
-       regcache_cache_only(cs42l73->regmap, true);
-
        cs42l73_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
-       cs42l73->mclksel = CS42L73_CLKID_MCLK1; /* MCLK1 as master clk */
+       /* Set Charge Pump Frequency */
+       if (cs42l73->pdata.chgfreq)
+               snd_soc_update_bits(codec, CS42L73_CPFCHC,
+                                   CS42L73_CHARGEPUMP_MASK,
+                                       cs42l73->pdata.chgfreq << 4);
+
+       /* MCLK1 as master clk */
+       cs42l73->mclksel = CS42L73_CLKID_MCLK1;
        cs42l73->mclk = 0;
 
        return ret;
@@ -1415,9 +1412,11 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
                             const struct i2c_device_id *id)
 {
        struct cs42l73_private *cs42l73;
+       struct cs42l73_platform_data *pdata = dev_get_platdata(&i2c_client->dev);
        int ret;
        unsigned int devid = 0;
        unsigned int reg;
+       u32 val32;
 
        cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private),
                               GFP_KERNEL);
@@ -1426,14 +1425,49 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
                return -ENOMEM;
        }
 
-       i2c_set_clientdata(i2c_client, cs42l73);
-
        cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap);
        if (IS_ERR(cs42l73->regmap)) {
                ret = PTR_ERR(cs42l73->regmap);
                dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret);
                return ret;
        }
+
+       if (pdata) {
+               cs42l73->pdata = *pdata;
+       } else {
+               pdata = devm_kzalloc(&i2c_client->dev,
+                                    sizeof(struct cs42l73_platform_data),
+                               GFP_KERNEL);
+               if (!pdata) {
+                       dev_err(&i2c_client->dev, "could not allocate pdata\n");
+                       return -ENOMEM;
+               }
+               if (i2c_client->dev.of_node) {
+                       if (of_property_read_u32(i2c_client->dev.of_node,
+                               "chgfreq", &val32) >= 0)
+                               pdata->chgfreq = val32;
+               }
+               pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node,
+                                               "reset-gpio", 0);
+               cs42l73->pdata = *pdata;
+       }
+
+       i2c_set_clientdata(i2c_client, cs42l73);
+
+       if (cs42l73->pdata.reset_gpio) {
+               ret = gpio_request_one(cs42l73->pdata.reset_gpio,
+                                      GPIOF_OUT_INIT_HIGH, "CS42L73 /RST");
+               if (ret < 0) {
+                       dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n",
+                               cs42l73->pdata.reset_gpio, ret);
+                       return ret;
+               }
+               gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0);
+               gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 1);
+       }
+
+       regcache_cache_bypass(cs42l73->regmap, true);
+
        /* initialize codec */
        ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, &reg);
        devid = (reg & 0xFF) << 12;
@@ -1444,7 +1478,6 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
        ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, &reg);
        devid |= (reg & 0xF0) >> 4;
 
-
        if (devid != CS42L73_DEVID) {
                ret = -ENODEV;
                dev_err(&i2c_client->dev,
@@ -1462,7 +1495,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
        dev_info(&i2c_client->dev,
                 "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF);
 
-       regcache_cache_only(cs42l73->regmap, true);
+       regcache_cache_bypass(cs42l73->regmap, false);
 
        ret =  snd_soc_register_codec(&i2c_client->dev,
                        &soc_codec_dev_cs42l73, cs42l73_dai,
@@ -1478,6 +1511,12 @@ static int cs42l73_i2c_remove(struct i2c_client *client)
        return 0;
 }
 
+static const struct of_device_id cs42l73_of_match[] = {
+       { .compatible = "cirrus,cs42l73", },
+       {},
+};
+MODULE_DEVICE_TABLE(of, cs42l73_of_match);
+
 static const struct i2c_device_id cs42l73_id[] = {
        {"cs42l73", 0},
        {}
@@ -1489,6 +1528,7 @@ static struct i2c_driver cs42l73_i2c_driver = {
        .driver = {
                   .name = "cs42l73",
                   .owner = THIS_MODULE,
+                  .of_match_table = cs42l73_of_match,
                   },
        .id_table = cs42l73_id,
        .probe = cs42l73_i2c_probe,
index f30a4c4d62e6a08cbf125d41bd4405657678aeb9..45746186a67820fd40678e452fc7b67a790ac69a 100644 (file)
 /* Bitfield Definitions */
 
 /* CS42L73_PWRCTL1 */
-#define PDN_ADCB               (1 << 7)
-#define PDN_DMICB              (1 << 6)
-#define PDN_ADCA               (1 << 5)
-#define PDN_DMICA              (1 << 4)
-#define PDN_LDO                        (1 << 2)
-#define DISCHG_FILT            (1 << 1)
-#define PDN                    (1 << 0)
+#define CS42L73_PDN_ADCB               (1 << 7)
+#define CS42L73_PDN_DMICB              (1 << 6)
+#define CS42L73_PDN_ADCA               (1 << 5)
+#define CS42L73_PDN_DMICA              (1 << 4)
+#define CS42L73_PDN_LDO                        (1 << 2)
+#define CS42L73_DISCHG_FILT            (1 << 1)
+#define CS42L73_PDN                    (1 << 0)
 
 /* CS42L73_PWRCTL2 */
-#define PDN_MIC2_BIAS          (1 << 7)
-#define PDN_MIC1_BIAS          (1 << 6)
-#define PDN_VSP                        (1 << 4)
-#define PDN_ASP_SDOUT          (1 << 3)
-#define PDN_ASP_SDIN           (1 << 2)
-#define PDN_XSP_SDOUT          (1 << 1)
-#define PDN_XSP_SDIN           (1 << 0)
+#define CS42L73_PDN_MIC2_BIAS          (1 << 7)
+#define CS42L73_PDN_MIC1_BIAS          (1 << 6)
+#define CS42L73_PDN_VSP                        (1 << 4)
+#define CS42L73_PDN_ASP_SDOUT          (1 << 3)
+#define CS42L73_PDN_ASP_SDIN           (1 << 2)
+#define CS42L73_PDN_XSP_SDOUT          (1 << 1)
+#define CS42L73_PDN_XSP_SDIN           (1 << 0)
 
 /* CS42L73_PWRCTL3 */
-#define PDN_THMS               (1 << 5)
-#define PDN_SPKLO              (1 << 4)
-#define PDN_EAR                        (1 << 3)
-#define PDN_SPK                        (1 << 2)
-#define PDN_LO                 (1 << 1)
-#define PDN_HP                 (1 << 0)
+#define CS42L73_PDN_THMS               (1 << 5)
+#define CS42L73_PDN_SPKLO              (1 << 4)
+#define CS42L73_PDN_EAR                        (1 << 3)
+#define CS42L73_PDN_SPK                        (1 << 2)
+#define CS42L73_PDN_LO                 (1 << 1)
+#define CS42L73_PDN_HP                 (1 << 0)
 
 /* Thermal Overload Detect. Requires interrupt ... */
-#define THMOVLD_150C           0
-#define THMOVLD_132C           1
-#define THMOVLD_115C           2
-#define THMOVLD_098C           3
+#define CS42L73_THMOVLD_150C           0
+#define CS42L73_THMOVLD_132C           1
+#define CS42L73_THMOVLD_115C           2
+#define CS42L73_THMOVLD_098C           3
 
+#define CS42L73_CHARGEPUMP_MASK        (0xF0)
 
 /* CS42L73_ASPC, CS42L73_XSPC, CS42L73_VSPC */
-#define        SP_3ST                  (1 << 7)
-#define SPDIF_I2S              (0 << 6)
-#define SPDIF_PCM              (1 << 6)
-#define PCM_MODE0              (0 << 4)
-#define PCM_MODE1              (1 << 4)
-#define PCM_MODE2              (2 << 4)
-#define PCM_MODE_MASK          (3 << 4)
-#define PCM_BIT_ORDER          (1 << 3)
-#define MCK_SCLK_64FS          (0 << 0)
-#define MCK_SCLK_MCLK          (2 << 0)
-#define MCK_SCLK_PREMCLK       (3 << 0)
+#define        CS42L73_SP_3ST                  (1 << 7)
+#define CS42L73_SPDIF_I2S              (0 << 6)
+#define CS42L73_SPDIF_PCM              (1 << 6)
+#define CS42L73_PCM_MODE0              (0 << 4)
+#define CS42L73_PCM_MODE1              (1 << 4)
+#define CS42L73_PCM_MODE2              (2 << 4)
+#define CS42L73_PCM_MODE_MASK          (3 << 4)
+#define CS42L73_PCM_BIT_ORDER          (1 << 3)
+#define CS42L73_MCK_SCLK_64FS          (0 << 0)
+#define CS42L73_MCK_SCLK_MCLK          (2 << 0)
+#define CS42L73_MCK_SCLK_PREMCLK       (3 << 0)
 
 /* CS42L73_xSPMMCC */
-#define MS_MASTER              (1 << 7)
+#define CS42L73_MS_MASTER              (1 << 7)
 
 
 /* CS42L73_DMMCC */
-#define MCLKDIS                        (1 << 0)
-#define MCLKSEL_MCLK2          (1 << 4)
-#define MCLKSEL_MCLK1          (0 << 4)
+#define CS42L73_MCLKDIS                        (1 << 0)
+#define CS42L73_MCLKSEL_MCLK2          (1 << 4)
+#define CS42L73_MCLKSEL_MCLK1          (0 << 4)
 
 /* CS42L73 MCLK derived from MCLK1 or MCLK2 */
 #define CS42L73_CLKID_MCLK1     0
 #define CS42L73_VSP            2
 
 /* IS1, IM1 */
-#define MIC2_SDET              (1 << 6)
-#define THMOVLD                        (1 << 4)
-#define DIGMIXOVFL             (1 << 3)
-#define IPBOVFL                        (1 << 1)
-#define IPAOVFL                        (1 << 0)
+#define CS42L73_MIC2_SDET              (1 << 6)
+#define CS42L73_THMOVLD                        (1 << 4)
+#define CS42L73_DIGMIXOVFL             (1 << 3)
+#define CS42L73_IPBOVFL                        (1 << 1)
+#define CS42L73_IPAOVFL                        (1 << 0)
 
 /* Analog Softramp */
-#define ANLGOSFT               (1 << 0)
+#define CS42L73_ANLGOSFT               (1 << 0)
 
 /* HP A/B Analog Mute */
-#define HPA_MUTE               (1 << 7)
+#define CS42L73_HPA_MUTE               (1 << 7)
 /* LO A/B Analog Mute  */
-#define LOA_MUTE               (1 << 7)
+#define CS42L73_LOA_MUTE               (1 << 7)
 /* Digital Mute */
-#define HLAD_MUTE              (1 << 0)
-#define HLBD_MUTE              (1 << 1)
-#define SPKD_MUTE              (1 << 2)
-#define ESLD_MUTE              (1 << 3)
+#define CS42L73_HLAD_MUTE              (1 << 0)
+#define CS42L73_HLBD_MUTE              (1 << 1)
+#define CS42L73_SPKD_MUTE              (1 << 2)
+#define CS42L73_ESLD_MUTE              (1 << 3)
 
 /* Misc defines for codec */
-#define CS42L73_RESET_GPIO 143
-
 #define CS42L73_DEVID          0x00042A73
 #define CS42L73_MCLKX_MIN      5644800
 #define CS42L73_MCLKX_MAX      38400000
index 566a367c94fa0ce71ac04f86686923ed63ece58d..66ceee22fdadd923225f1b7001b208c3c1b1fde6 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
+#include <linux/regmap.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -38,294 +39,223 @@ struct max98088_cdata {
 };
 
 struct max98088_priv {
-       enum max98088_type devtype;
-       struct max98088_pdata *pdata;
-       unsigned int sysclk;
-       struct max98088_cdata dai[2];
-       int eq_textcnt;
-       const char **eq_texts;
-       struct soc_enum eq_enum;
-       u8 ina_state;
-       u8 inb_state;
-       unsigned int ex_mode;
-       unsigned int digmic;
-       unsigned int mic1pre;
-       unsigned int mic2pre;
-       unsigned int extmic_mode;
+       struct regmap *regmap;
+       enum max98088_type devtype;
+       struct max98088_pdata *pdata;
+       unsigned int sysclk;
+       struct max98088_cdata dai[2];
+       int eq_textcnt;
+       const char **eq_texts;
+       struct soc_enum eq_enum;
+       u8 ina_state;
+       u8 inb_state;
+       unsigned int ex_mode;
+       unsigned int digmic;
+       unsigned int mic1pre;
+       unsigned int mic2pre;
+       unsigned int extmic_mode;
 };
 
-static const u8 max98088_reg[M98088_REG_CNT] = {
-       0x00, /* 00 IRQ status */
-       0x00, /* 01 MIC status */
-       0x00, /* 02 jack status */
-       0x00, /* 03 battery voltage */
-       0x00, /* 04 */
-       0x00, /* 05 */
-       0x00, /* 06 */
-       0x00, /* 07 */
-       0x00, /* 08 */
-       0x00, /* 09 */
-       0x00, /* 0A */
-       0x00, /* 0B */
-       0x00, /* 0C */
-       0x00, /* 0D */
-       0x00, /* 0E */
-       0x00, /* 0F interrupt enable */
-
-       0x00, /* 10 master clock */
-       0x00, /* 11 DAI1 clock mode */
-       0x00, /* 12 DAI1 clock control */
-       0x00, /* 13 DAI1 clock control */
-       0x00, /* 14 DAI1 format */
-       0x00, /* 15 DAI1 clock */
-       0x00, /* 16 DAI1 config */
-       0x00, /* 17 DAI1 TDM */
-       0x00, /* 18 DAI1 filters */
-       0x00, /* 19 DAI2 clock mode */
-       0x00, /* 1A DAI2 clock control */
-       0x00, /* 1B DAI2 clock control */
-       0x00, /* 1C DAI2 format */
-       0x00, /* 1D DAI2 clock */
-       0x00, /* 1E DAI2 config */
-       0x00, /* 1F DAI2 TDM */
-
-       0x00, /* 20 DAI2 filters */
-       0x00, /* 21 data config */
-       0x00, /* 22 DAC mixer */
-       0x00, /* 23 left ADC mixer */
-       0x00, /* 24 right ADC mixer */
-       0x00, /* 25 left HP mixer */
-       0x00, /* 26 right HP mixer */
-       0x00, /* 27 HP control */
-       0x00, /* 28 left REC mixer */
-       0x00, /* 29 right REC mixer */
-       0x00, /* 2A REC control */
-       0x00, /* 2B left SPK mixer */
-       0x00, /* 2C right SPK mixer */
-       0x00, /* 2D SPK control */
-       0x00, /* 2E sidetone */
-       0x00, /* 2F DAI1 playback level */
-
-       0x00, /* 30 DAI1 playback level */
-       0x00, /* 31 DAI2 playback level */
-       0x00, /* 32 DAI2 playbakc level */
-       0x00, /* 33 left ADC level */
-       0x00, /* 34 right ADC level */
-       0x00, /* 35 MIC1 level */
-       0x00, /* 36 MIC2 level */
-       0x00, /* 37 INA level */
-       0x00, /* 38 INB level */
-       0x00, /* 39 left HP volume */
-       0x00, /* 3A right HP volume */
-       0x00, /* 3B left REC volume */
-       0x00, /* 3C right REC volume */
-       0x00, /* 3D left SPK volume */
-       0x00, /* 3E right SPK volume */
-       0x00, /* 3F MIC config */
-
-       0x00, /* 40 MIC threshold */
-       0x00, /* 41 excursion limiter filter */
-       0x00, /* 42 excursion limiter threshold */
-       0x00, /* 43 ALC */
-       0x00, /* 44 power limiter threshold */
-       0x00, /* 45 power limiter config */
-       0x00, /* 46 distortion limiter config */
-       0x00, /* 47 audio input */
-       0x00, /* 48 microphone */
-       0x00, /* 49 level control */
-       0x00, /* 4A bypass switches */
-       0x00, /* 4B jack detect */
-       0x00, /* 4C input enable */
-       0x00, /* 4D output enable */
-       0xF0, /* 4E bias control */
-       0x00, /* 4F DAC power */
-
-       0x0F, /* 50 DAC power */
-       0x00, /* 51 system */
-       0x00, /* 52 DAI1 EQ1 */
-       0x00, /* 53 DAI1 EQ1 */
-       0x00, /* 54 DAI1 EQ1 */
-       0x00, /* 55 DAI1 EQ1 */
-       0x00, /* 56 DAI1 EQ1 */
-       0x00, /* 57 DAI1 EQ1 */
-       0x00, /* 58 DAI1 EQ1 */
-       0x00, /* 59 DAI1 EQ1 */
-       0x00, /* 5A DAI1 EQ1 */
-       0x00, /* 5B DAI1 EQ1 */
-       0x00, /* 5C DAI1 EQ2 */
-       0x00, /* 5D DAI1 EQ2 */
-       0x00, /* 5E DAI1 EQ2 */
-       0x00, /* 5F DAI1 EQ2 */
-
-       0x00, /* 60 DAI1 EQ2 */
-       0x00, /* 61 DAI1 EQ2 */
-       0x00, /* 62 DAI1 EQ2 */
-       0x00, /* 63 DAI1 EQ2 */
-       0x00, /* 64 DAI1 EQ2 */
-       0x00, /* 65 DAI1 EQ2 */
-       0x00, /* 66 DAI1 EQ3 */
-       0x00, /* 67 DAI1 EQ3 */
-       0x00, /* 68 DAI1 EQ3 */
-       0x00, /* 69 DAI1 EQ3 */
-       0x00, /* 6A DAI1 EQ3 */
-       0x00, /* 6B DAI1 EQ3 */
-       0x00, /* 6C DAI1 EQ3 */
-       0x00, /* 6D DAI1 EQ3 */
-       0x00, /* 6E DAI1 EQ3 */
-       0x00, /* 6F DAI1 EQ3 */
-
-       0x00, /* 70 DAI1 EQ4 */
-       0x00, /* 71 DAI1 EQ4 */
-       0x00, /* 72 DAI1 EQ4 */
-       0x00, /* 73 DAI1 EQ4 */
-       0x00, /* 74 DAI1 EQ4 */
-       0x00, /* 75 DAI1 EQ4 */
-       0x00, /* 76 DAI1 EQ4 */
-       0x00, /* 77 DAI1 EQ4 */
-       0x00, /* 78 DAI1 EQ4 */
-       0x00, /* 79 DAI1 EQ4 */
-       0x00, /* 7A DAI1 EQ5 */
-       0x00, /* 7B DAI1 EQ5 */
-       0x00, /* 7C DAI1 EQ5 */
-       0x00, /* 7D DAI1 EQ5 */
-       0x00, /* 7E DAI1 EQ5 */
-       0x00, /* 7F DAI1 EQ5 */
-
-       0x00, /* 80 DAI1 EQ5 */
-       0x00, /* 81 DAI1 EQ5 */
-       0x00, /* 82 DAI1 EQ5 */
-       0x00, /* 83 DAI1 EQ5 */
-       0x00, /* 84 DAI2 EQ1 */
-       0x00, /* 85 DAI2 EQ1 */
-       0x00, /* 86 DAI2 EQ1 */
-       0x00, /* 87 DAI2 EQ1 */
-       0x00, /* 88 DAI2 EQ1 */
-       0x00, /* 89 DAI2 EQ1 */
-       0x00, /* 8A DAI2 EQ1 */
-       0x00, /* 8B DAI2 EQ1 */
-       0x00, /* 8C DAI2 EQ1 */
-       0x00, /* 8D DAI2 EQ1 */
-       0x00, /* 8E DAI2 EQ2 */
-       0x00, /* 8F DAI2 EQ2 */
-
-       0x00, /* 90 DAI2 EQ2 */
-       0x00, /* 91 DAI2 EQ2 */
-       0x00, /* 92 DAI2 EQ2 */
-       0x00, /* 93 DAI2 EQ2 */
-       0x00, /* 94 DAI2 EQ2 */
-       0x00, /* 95 DAI2 EQ2 */
-       0x00, /* 96 DAI2 EQ2 */
-       0x00, /* 97 DAI2 EQ2 */
-       0x00, /* 98 DAI2 EQ3 */
-       0x00, /* 99 DAI2 EQ3 */
-       0x00, /* 9A DAI2 EQ3 */
-       0x00, /* 9B DAI2 EQ3 */
-       0x00, /* 9C DAI2 EQ3 */
-       0x00, /* 9D DAI2 EQ3 */
-       0x00, /* 9E DAI2 EQ3 */
-       0x00, /* 9F DAI2 EQ3 */
-
-       0x00, /* A0 DAI2 EQ3 */
-       0x00, /* A1 DAI2 EQ3 */
-       0x00, /* A2 DAI2 EQ4 */
-       0x00, /* A3 DAI2 EQ4 */
-       0x00, /* A4 DAI2 EQ4 */
-       0x00, /* A5 DAI2 EQ4 */
-       0x00, /* A6 DAI2 EQ4 */
-       0x00, /* A7 DAI2 EQ4 */
-       0x00, /* A8 DAI2 EQ4 */
-       0x00, /* A9 DAI2 EQ4 */
-       0x00, /* AA DAI2 EQ4 */
-       0x00, /* AB DAI2 EQ4 */
-       0x00, /* AC DAI2 EQ5 */
-       0x00, /* AD DAI2 EQ5 */
-       0x00, /* AE DAI2 EQ5 */
-       0x00, /* AF DAI2 EQ5 */
-
-       0x00, /* B0 DAI2 EQ5 */
-       0x00, /* B1 DAI2 EQ5 */
-       0x00, /* B2 DAI2 EQ5 */
-       0x00, /* B3 DAI2 EQ5 */
-       0x00, /* B4 DAI2 EQ5 */
-       0x00, /* B5 DAI2 EQ5 */
-       0x00, /* B6 DAI1 biquad */
-       0x00, /* B7 DAI1 biquad */
-       0x00, /* B8 DAI1 biquad */
-       0x00, /* B9 DAI1 biquad */
-       0x00, /* BA DAI1 biquad */
-       0x00, /* BB DAI1 biquad */
-       0x00, /* BC DAI1 biquad */
-       0x00, /* BD DAI1 biquad */
-       0x00, /* BE DAI1 biquad */
-       0x00, /* BF DAI1 biquad */
-
-       0x00, /* C0 DAI2 biquad */
-       0x00, /* C1 DAI2 biquad */
-       0x00, /* C2 DAI2 biquad */
-       0x00, /* C3 DAI2 biquad */
-       0x00, /* C4 DAI2 biquad */
-       0x00, /* C5 DAI2 biquad */
-       0x00, /* C6 DAI2 biquad */
-       0x00, /* C7 DAI2 biquad */
-       0x00, /* C8 DAI2 biquad */
-       0x00, /* C9 DAI2 biquad */
-       0x00, /* CA */
-       0x00, /* CB */
-       0x00, /* CC */
-       0x00, /* CD */
-       0x00, /* CE */
-       0x00, /* CF */
-
-       0x00, /* D0 */
-       0x00, /* D1 */
-       0x00, /* D2 */
-       0x00, /* D3 */
-       0x00, /* D4 */
-       0x00, /* D5 */
-       0x00, /* D6 */
-       0x00, /* D7 */
-       0x00, /* D8 */
-       0x00, /* D9 */
-       0x00, /* DA */
-       0x70, /* DB */
-       0x00, /* DC */
-       0x00, /* DD */
-       0x00, /* DE */
-       0x00, /* DF */
-
-       0x00, /* E0 */
-       0x00, /* E1 */
-       0x00, /* E2 */
-       0x00, /* E3 */
-       0x00, /* E4 */
-       0x00, /* E5 */
-       0x00, /* E6 */
-       0x00, /* E7 */
-       0x00, /* E8 */
-       0x00, /* E9 */
-       0x00, /* EA */
-       0x00, /* EB */
-       0x00, /* EC */
-       0x00, /* ED */
-       0x00, /* EE */
-       0x00, /* EF */
-
-       0x00, /* F0 */
-       0x00, /* F1 */
-       0x00, /* F2 */
-       0x00, /* F3 */
-       0x00, /* F4 */
-       0x00, /* F5 */
-       0x00, /* F6 */
-       0x00, /* F7 */
-       0x00, /* F8 */
-       0x00, /* F9 */
-       0x00, /* FA */
-       0x00, /* FB */
-       0x00, /* FC */
-       0x00, /* FD */
-       0x00, /* FE */
-       0x00, /* FF */
+static const struct reg_default max98088_reg[] = {
+       {  0xf, 0x00 }, /* 0F interrupt enable */
+
+       { 0x10, 0x00 }, /* 10 master clock */
+       { 0x11, 0x00 }, /* 11 DAI1 clock mode */
+       { 0x12, 0x00 }, /* 12 DAI1 clock control */
+       { 0x13, 0x00 }, /* 13 DAI1 clock control */
+       { 0x14, 0x00 }, /* 14 DAI1 format */
+       { 0x15, 0x00 }, /* 15 DAI1 clock */
+       { 0x16, 0x00 }, /* 16 DAI1 config */
+       { 0x17, 0x00 }, /* 17 DAI1 TDM */
+       { 0x18, 0x00 }, /* 18 DAI1 filters */
+       { 0x19, 0x00 }, /* 19 DAI2 clock mode */
+       { 0x1a, 0x00 }, /* 1A DAI2 clock control */
+       { 0x1b, 0x00 }, /* 1B DAI2 clock control */
+       { 0x1c, 0x00 }, /* 1C DAI2 format */
+       { 0x1d, 0x00 }, /* 1D DAI2 clock */
+       { 0x1e, 0x00 }, /* 1E DAI2 config */
+       { 0x1f, 0x00 }, /* 1F DAI2 TDM */
+
+       { 0x20, 0x00 }, /* 20 DAI2 filters */
+       { 0x21, 0x00 }, /* 21 data config */
+       { 0x22, 0x00 }, /* 22 DAC mixer */
+       { 0x23, 0x00 }, /* 23 left ADC mixer */
+       { 0x24, 0x00 }, /* 24 right ADC mixer */
+       { 0x25, 0x00 }, /* 25 left HP mixer */
+       { 0x26, 0x00 }, /* 26 right HP mixer */
+       { 0x27, 0x00 }, /* 27 HP control */
+       { 0x28, 0x00 }, /* 28 left REC mixer */
+       { 0x29, 0x00 }, /* 29 right REC mixer */
+       { 0x2a, 0x00 }, /* 2A REC control */
+       { 0x2b, 0x00 }, /* 2B left SPK mixer */
+       { 0x2c, 0x00 }, /* 2C right SPK mixer */
+       { 0x2d, 0x00 }, /* 2D SPK control */
+       { 0x2e, 0x00 }, /* 2E sidetone */
+       { 0x2f, 0x00 }, /* 2F DAI1 playback level */
+
+       { 0x30, 0x00 }, /* 30 DAI1 playback level */
+       { 0x31, 0x00 }, /* 31 DAI2 playback level */
+       { 0x32, 0x00 }, /* 32 DAI2 playbakc level */
+       { 0x33, 0x00 }, /* 33 left ADC level */
+       { 0x34, 0x00 }, /* 34 right ADC level */
+       { 0x35, 0x00 }, /* 35 MIC1 level */
+       { 0x36, 0x00 }, /* 36 MIC2 level */
+       { 0x37, 0x00 }, /* 37 INA level */
+       { 0x38, 0x00 }, /* 38 INB level */
+       { 0x39, 0x00 }, /* 39 left HP volume */
+       { 0x3a, 0x00 }, /* 3A right HP volume */
+       { 0x3b, 0x00 }, /* 3B left REC volume */
+       { 0x3c, 0x00 }, /* 3C right REC volume */
+       { 0x3d, 0x00 }, /* 3D left SPK volume */
+       { 0x3e, 0x00 }, /* 3E right SPK volume */
+       { 0x3f, 0x00 }, /* 3F MIC config */
+
+       { 0x40, 0x00 }, /* 40 MIC threshold */
+       { 0x41, 0x00 }, /* 41 excursion limiter filter */
+       { 0x42, 0x00 }, /* 42 excursion limiter threshold */
+       { 0x43, 0x00 }, /* 43 ALC */
+       { 0x44, 0x00 }, /* 44 power limiter threshold */
+       { 0x45, 0x00 }, /* 45 power limiter config */
+       { 0x46, 0x00 }, /* 46 distortion limiter config */
+       { 0x47, 0x00 }, /* 47 audio input */
+        { 0x48, 0x00 }, /* 48 microphone */
+       { 0x49, 0x00 }, /* 49 level control */
+       { 0x4a, 0x00 }, /* 4A bypass switches */
+       { 0x4b, 0x00 }, /* 4B jack detect */
+       { 0x4c, 0x00 }, /* 4C input enable */
+       { 0x4d, 0x00 }, /* 4D output enable */
+       { 0x4e, 0xF0 }, /* 4E bias control */
+       { 0x4f, 0x00 }, /* 4F DAC power */
+
+       { 0x50, 0x0F }, /* 50 DAC power */
+       { 0x51, 0x00 }, /* 51 system */
+       { 0x52, 0x00 }, /* 52 DAI1 EQ1 */
+       { 0x53, 0x00 }, /* 53 DAI1 EQ1 */
+       { 0x54, 0x00 }, /* 54 DAI1 EQ1 */
+       { 0x55, 0x00 }, /* 55 DAI1 EQ1 */
+       { 0x56, 0x00 }, /* 56 DAI1 EQ1 */
+       { 0x57, 0x00 }, /* 57 DAI1 EQ1 */
+       { 0x58, 0x00 }, /* 58 DAI1 EQ1 */
+       { 0x59, 0x00 }, /* 59 DAI1 EQ1 */
+       { 0x5a, 0x00 }, /* 5A DAI1 EQ1 */
+       { 0x5b, 0x00 }, /* 5B DAI1 EQ1 */
+       { 0x5c, 0x00 }, /* 5C DAI1 EQ2 */
+       { 0x5d, 0x00 }, /* 5D DAI1 EQ2 */
+       { 0x5e, 0x00 }, /* 5E DAI1 EQ2 */
+       { 0x5f, 0x00 }, /* 5F DAI1 EQ2 */
+
+       { 0x60, 0x00 }, /* 60 DAI1 EQ2 */
+       { 0x61, 0x00 }, /* 61 DAI1 EQ2 */
+       { 0x62, 0x00 }, /* 62 DAI1 EQ2 */
+       { 0x63, 0x00 }, /* 63 DAI1 EQ2 */
+       { 0x64, 0x00 }, /* 64 DAI1 EQ2 */
+       { 0x65, 0x00 }, /* 65 DAI1 EQ2 */
+       { 0x66, 0x00 }, /* 66 DAI1 EQ3 */
+       { 0x67, 0x00 }, /* 67 DAI1 EQ3 */
+       { 0x68, 0x00 }, /* 68 DAI1 EQ3 */
+       { 0x69, 0x00 }, /* 69 DAI1 EQ3 */
+       { 0x6a, 0x00 }, /* 6A DAI1 EQ3 */
+       { 0x6b, 0x00 }, /* 6B DAI1 EQ3 */
+       { 0x6c, 0x00 }, /* 6C DAI1 EQ3 */
+       { 0x6d, 0x00 }, /* 6D DAI1 EQ3 */
+       { 0x6e, 0x00 }, /* 6E DAI1 EQ3 */
+       { 0x6f, 0x00 }, /* 6F DAI1 EQ3 */
+
+       { 0x70, 0x00 }, /* 70 DAI1 EQ4 */
+       { 0x71, 0x00 }, /* 71 DAI1 EQ4 */
+       { 0x72, 0x00 }, /* 72 DAI1 EQ4 */
+       { 0x73, 0x00 }, /* 73 DAI1 EQ4 */
+       { 0x74, 0x00 }, /* 74 DAI1 EQ4 */
+       { 0x75, 0x00 }, /* 75 DAI1 EQ4 */
+       { 0x76, 0x00 }, /* 76 DAI1 EQ4 */
+       { 0x77, 0x00 }, /* 77 DAI1 EQ4 */
+       { 0x78, 0x00 }, /* 78 DAI1 EQ4 */
+       { 0x79, 0x00 }, /* 79 DAI1 EQ4 */
+       { 0x7a, 0x00 }, /* 7A DAI1 EQ5 */
+       { 0x7b, 0x00 }, /* 7B DAI1 EQ5 */
+       { 0x7c, 0x00 }, /* 7C DAI1 EQ5 */
+       { 0x7d, 0x00 }, /* 7D DAI1 EQ5 */
+       { 0x7e, 0x00 }, /* 7E DAI1 EQ5 */
+       { 0x7f, 0x00 }, /* 7F DAI1 EQ5 */
+
+       { 0x80, 0x00 }, /* 80 DAI1 EQ5 */
+       { 0x81, 0x00 }, /* 81 DAI1 EQ5 */
+       { 0x82, 0x00 }, /* 82 DAI1 EQ5 */
+       { 0x83, 0x00 }, /* 83 DAI1 EQ5 */
+       { 0x84, 0x00 }, /* 84 DAI2 EQ1 */
+       { 0x85, 0x00 }, /* 85 DAI2 EQ1 */
+       { 0x86, 0x00 }, /* 86 DAI2 EQ1 */
+       { 0x87, 0x00 }, /* 87 DAI2 EQ1 */
+       { 0x88, 0x00 }, /* 88 DAI2 EQ1 */
+       { 0x89, 0x00 }, /* 89 DAI2 EQ1 */
+       { 0x8a, 0x00 }, /* 8A DAI2 EQ1 */
+       { 0x8b, 0x00 }, /* 8B DAI2 EQ1 */
+       { 0x8c, 0x00 }, /* 8C DAI2 EQ1 */
+       { 0x8d, 0x00 }, /* 8D DAI2 EQ1 */
+       { 0x8e, 0x00 }, /* 8E DAI2 EQ2 */
+       { 0x8f, 0x00 }, /* 8F DAI2 EQ2 */
+
+       { 0x90, 0x00 }, /* 90 DAI2 EQ2 */
+       { 0x91, 0x00 }, /* 91 DAI2 EQ2 */
+       { 0x92, 0x00 }, /* 92 DAI2 EQ2 */
+       { 0x93, 0x00 }, /* 93 DAI2 EQ2 */
+       { 0x94, 0x00 }, /* 94 DAI2 EQ2 */
+       { 0x95, 0x00 }, /* 95 DAI2 EQ2 */
+       { 0x96, 0x00 }, /* 96 DAI2 EQ2 */
+       { 0x97, 0x00 }, /* 97 DAI2 EQ2 */
+       { 0x98, 0x00 }, /* 98 DAI2 EQ3 */
+       { 0x99, 0x00 }, /* 99 DAI2 EQ3 */
+       { 0x9a, 0x00 }, /* 9A DAI2 EQ3 */
+        { 0x9b, 0x00 }, /* 9B DAI2 EQ3 */
+       { 0x9c, 0x00 }, /* 9C DAI2 EQ3 */
+       { 0x9d, 0x00 }, /* 9D DAI2 EQ3 */
+       { 0x9e, 0x00 }, /* 9E DAI2 EQ3 */
+       { 0x9f, 0x00 }, /* 9F DAI2 EQ3 */
+
+       { 0xa0, 0x00 }, /* A0 DAI2 EQ3 */
+       { 0xa1, 0x00 }, /* A1 DAI2 EQ3 */
+       { 0xa2, 0x00 }, /* A2 DAI2 EQ4 */
+       { 0xa3, 0x00 }, /* A3 DAI2 EQ4 */
+       { 0xa4, 0x00 }, /* A4 DAI2 EQ4 */
+       { 0xa5, 0x00 }, /* A5 DAI2 EQ4 */
+       { 0xa6, 0x00 }, /* A6 DAI2 EQ4 */
+       { 0xa7, 0x00 }, /* A7 DAI2 EQ4 */
+       { 0xa8, 0x00 }, /* A8 DAI2 EQ4 */
+       { 0xa9, 0x00 }, /* A9 DAI2 EQ4 */
+       { 0xaa, 0x00 }, /* AA DAI2 EQ4 */
+       { 0xab, 0x00 }, /* AB DAI2 EQ4 */
+       { 0xac, 0x00 }, /* AC DAI2 EQ5 */
+       { 0xad, 0x00 }, /* AD DAI2 EQ5 */
+       { 0xae, 0x00 }, /* AE DAI2 EQ5 */
+       { 0xaf, 0x00 }, /* AF DAI2 EQ5 */
+
+       { 0xb0, 0x00 }, /* B0 DAI2 EQ5 */
+       { 0xb1, 0x00 }, /* B1 DAI2 EQ5 */
+       { 0xb2, 0x00 }, /* B2 DAI2 EQ5 */
+       { 0xb3, 0x00 }, /* B3 DAI2 EQ5 */
+       { 0xb4, 0x00 }, /* B4 DAI2 EQ5 */
+       { 0xb5, 0x00 }, /* B5 DAI2 EQ5 */
+       { 0xb6, 0x00 }, /* B6 DAI1 biquad */
+       { 0xb7, 0x00 }, /* B7 DAI1 biquad */
+       { 0xb8 ,0x00 }, /* B8 DAI1 biquad */
+       { 0xb9, 0x00 }, /* B9 DAI1 biquad */
+       { 0xba, 0x00 }, /* BA DAI1 biquad */
+       { 0xbb, 0x00 }, /* BB DAI1 biquad */
+       { 0xbc, 0x00 }, /* BC DAI1 biquad */
+       { 0xbd, 0x00 }, /* BD DAI1 biquad */
+       { 0xbe, 0x00 }, /* BE DAI1 biquad */
+        { 0xbf, 0x00 }, /* BF DAI1 biquad */
+
+       { 0xc0, 0x00 }, /* C0 DAI2 biquad */
+       { 0xc1, 0x00 }, /* C1 DAI2 biquad */
+       { 0xc2, 0x00 }, /* C2 DAI2 biquad */
+       { 0xc3, 0x00 }, /* C3 DAI2 biquad */
+       { 0xc4, 0x00 }, /* C4 DAI2 biquad */
+       { 0xc5, 0x00 }, /* C5 DAI2 biquad */
+       { 0xc6, 0x00 }, /* C6 DAI2 biquad */
+       { 0xc7, 0x00 }, /* C7 DAI2 biquad */
+       { 0xc8, 0x00 }, /* C8 DAI2 biquad */
+       { 0xc9, 0x00 }, /* C9 DAI2 biquad */
 };
 
 static struct {
@@ -606,11 +536,28 @@ static struct {
        { 0xFF, 0x00, 1 }, /* FF */
 };
 
-static int max98088_volatile_register(struct snd_soc_codec *codec, unsigned int reg)
+static bool max98088_readable_register(struct device *dev, unsigned int reg)
+{
+       return max98088_access[reg].readable;
+}
+
+static bool max98088_volatile_register(struct device *dev, unsigned int reg)
 {
        return max98088_access[reg].vol;
 }
 
+static const struct regmap_config max98088_regmap = {
+       .reg_bits = 8,
+       .val_bits = 8,
+
+       .readable_reg = max98088_readable_register,
+       .volatile_reg = max98088_volatile_register,
+       .max_register = 0xff,
+
+       .reg_defaults = max98088_reg,
+       .num_reg_defaults = ARRAY_SIZE(max98088_reg),
+       .cache_type = REGCACHE_RBTREE,
+};
 
 /*
  * Load equalizer DSP coefficient configurations registers
@@ -1610,58 +1557,34 @@ static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute)
        return 0;
 }
 
-static void max98088_sync_cache(struct snd_soc_codec *codec)
-{
-       u8 *reg_cache = codec->reg_cache;
-       int i;
-
-       if (!codec->cache_sync)
-               return;
-
-       codec->cache_only = 0;
-
-       /* write back cached values if they're writeable and
-        * different from the hardware default.
-        */
-       for (i = 1; i < codec->driver->reg_cache_size; i++) {
-               if (!max98088_access[i].writable)
-                       continue;
-
-               if (reg_cache[i] == max98088_reg[i])
-                       continue;
-
-               snd_soc_write(codec, i, reg_cache[i]);
-       }
-
-       codec->cache_sync = 0;
-}
-
 static int max98088_set_bias_level(struct snd_soc_codec *codec,
                                   enum snd_soc_bias_level level)
 {
-       switch (level) {
-       case SND_SOC_BIAS_ON:
-               break;
-
-       case SND_SOC_BIAS_PREPARE:
-               break;
-
-       case SND_SOC_BIAS_STANDBY:
-               if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
-                       max98088_sync_cache(codec);
-
-               snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN,
-                               M98088_MBEN, M98088_MBEN);
-               break;
-
-       case SND_SOC_BIAS_OFF:
-               snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN,
-                               M98088_MBEN, 0);
-               codec->cache_sync = 1;
-               break;
-       }
-       codec->dapm.bias_level = level;
-       return 0;
+       struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
+
+       switch (level) {
+       case SND_SOC_BIAS_ON:
+               break;
+
+       case SND_SOC_BIAS_PREPARE:
+               break;
+
+       case SND_SOC_BIAS_STANDBY:
+               if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
+                       regcache_sync(max98088->regmap);
+
+               snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN,
+                                  M98088_MBEN, M98088_MBEN);
+               break;
+
+       case SND_SOC_BIAS_OFF:
+               snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN,
+                                   M98088_MBEN, 0);
+               regcache_mark_dirty(max98088->regmap);
+               break;
+       }
+       codec->dapm.bias_level = level;
+       return 0;
 }
 
 #define MAX98088_RATES SNDRV_PCM_RATE_8000_96000
@@ -1988,9 +1911,9 @@ static int max98088_probe(struct snd_soc_codec *codec)
        struct max98088_cdata *cdata;
        int ret = 0;
 
-       codec->cache_sync = 1;
+       regcache_mark_dirty(max98088->regmap);
 
-       ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
+       ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
        if (ret != 0) {
                dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
                return ret;
@@ -2048,9 +1971,6 @@ static int max98088_probe(struct snd_soc_codec *codec)
 
        max98088_handle_pdata(codec);
 
-       snd_soc_add_codec_controls(codec, max98088_snd_controls,
-                            ARRAY_SIZE(max98088_snd_controls));
-
 err_access:
        return ret;
 }
@@ -2066,15 +1986,13 @@ static int max98088_remove(struct snd_soc_codec *codec)
 }
 
 static struct snd_soc_codec_driver soc_codec_dev_max98088 = {
-       .probe   = max98088_probe,
-       .remove  = max98088_remove,
-       .suspend = max98088_suspend,
-       .resume  = max98088_resume,
-       .set_bias_level = max98088_set_bias_level,
-       .reg_cache_size = ARRAY_SIZE(max98088_reg),
-       .reg_word_size = sizeof(u8),
-       .reg_cache_default = max98088_reg,
-       .volatile_register = max98088_volatile_register,
+       .probe   = max98088_probe,
+       .remove  = max98088_remove,
+       .suspend = max98088_suspend,
+       .resume  = max98088_resume,
+       .set_bias_level = max98088_set_bias_level,
+       .controls = max98088_snd_controls,
+       .num_controls = ARRAY_SIZE(max98088_snd_controls),
        .dapm_widgets = max98088_dapm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(max98088_dapm_widgets),
        .dapm_routes = max98088_audio_map,
@@ -2082,7 +2000,7 @@ static struct snd_soc_codec_driver soc_codec_dev_max98088 = {
 };
 
 static int max98088_i2c_probe(struct i2c_client *i2c,
-                            const struct i2c_device_id *id)
+                             const struct i2c_device_id *id)
 {
        struct max98088_priv *max98088;
        int ret;
@@ -2092,6 +2010,10 @@ static int max98088_i2c_probe(struct i2c_client *i2c,
        if (max98088 == NULL)
                return -ENOMEM;
 
+       max98088->regmap = devm_regmap_init_i2c(i2c, &max98088_regmap);
+       if (IS_ERR(max98088->regmap))
+              return PTR_ERR(max98088->regmap);
+
        max98088->devtype = id->driver_data;
 
        i2c_set_clientdata(i2c, max98088);
index 8dbcacd44e6aa5cbf5de1fba91ebdf16c1592ff8..8fb072455802e0daa82dfd8efce7ecc0758893e8 100644 (file)
@@ -39,6 +39,7 @@ struct max98095_cdata {
 };
 
 struct max98095_priv {
+       struct regmap *regmap;
        enum max98095_type devtype;
        struct max98095_pdata *pdata;
        unsigned int sysclk;
@@ -56,263 +57,145 @@ struct max98095_priv {
        struct snd_soc_jack *mic_jack;
 };
 
-static const u8 max98095_reg_def[M98095_REG_CNT] = {
-       0x00, /* 00 */
-       0x00, /* 01 */
-       0x00, /* 02 */
-       0x00, /* 03 */
-       0x00, /* 04 */
-       0x00, /* 05 */
-       0x00, /* 06 */
-       0x00, /* 07 */
-       0x00, /* 08 */
-       0x00, /* 09 */
-       0x00, /* 0A */
-       0x00, /* 0B */
-       0x00, /* 0C */
-       0x00, /* 0D */
-       0x00, /* 0E */
-       0x00, /* 0F */
-       0x00, /* 10 */
-       0x00, /* 11 */
-       0x00, /* 12 */
-       0x00, /* 13 */
-       0x00, /* 14 */
-       0x00, /* 15 */
-       0x00, /* 16 */
-       0x00, /* 17 */
-       0x00, /* 18 */
-       0x00, /* 19 */
-       0x00, /* 1A */
-       0x00, /* 1B */
-       0x00, /* 1C */
-       0x00, /* 1D */
-       0x00, /* 1E */
-       0x00, /* 1F */
-       0x00, /* 20 */
-       0x00, /* 21 */
-       0x00, /* 22 */
-       0x00, /* 23 */
-       0x00, /* 24 */
-       0x00, /* 25 */
-       0x00, /* 26 */
-       0x00, /* 27 */
-       0x00, /* 28 */
-       0x00, /* 29 */
-       0x00, /* 2A */
-       0x00, /* 2B */
-       0x00, /* 2C */
-       0x00, /* 2D */
-       0x00, /* 2E */
-       0x00, /* 2F */
-       0x00, /* 30 */
-       0x00, /* 31 */
-       0x00, /* 32 */
-       0x00, /* 33 */
-       0x00, /* 34 */
-       0x00, /* 35 */
-       0x00, /* 36 */
-       0x00, /* 37 */
-       0x00, /* 38 */
-       0x00, /* 39 */
-       0x00, /* 3A */
-       0x00, /* 3B */
-       0x00, /* 3C */
-       0x00, /* 3D */
-       0x00, /* 3E */
-       0x00, /* 3F */
-       0x00, /* 40 */
-       0x00, /* 41 */
-       0x00, /* 42 */
-       0x00, /* 43 */
-       0x00, /* 44 */
-       0x00, /* 45 */
-       0x00, /* 46 */
-       0x00, /* 47 */
-       0x00, /* 48 */
-       0x00, /* 49 */
-       0x00, /* 4A */
-       0x00, /* 4B */
-       0x00, /* 4C */
-       0x00, /* 4D */
-       0x00, /* 4E */
-       0x00, /* 4F */
-       0x00, /* 50 */
-       0x00, /* 51 */
-       0x00, /* 52 */
-       0x00, /* 53 */
-       0x00, /* 54 */
-       0x00, /* 55 */
-       0x00, /* 56 */
-       0x00, /* 57 */
-       0x00, /* 58 */
-       0x00, /* 59 */
-       0x00, /* 5A */
-       0x00, /* 5B */
-       0x00, /* 5C */
-       0x00, /* 5D */
-       0x00, /* 5E */
-       0x00, /* 5F */
-       0x00, /* 60 */
-       0x00, /* 61 */
-       0x00, /* 62 */
-       0x00, /* 63 */
-       0x00, /* 64 */
-       0x00, /* 65 */
-       0x00, /* 66 */
-       0x00, /* 67 */
-       0x00, /* 68 */
-       0x00, /* 69 */
-       0x00, /* 6A */
-       0x00, /* 6B */
-       0x00, /* 6C */
-       0x00, /* 6D */
-       0x00, /* 6E */
-       0x00, /* 6F */
-       0x00, /* 70 */
-       0x00, /* 71 */
-       0x00, /* 72 */
-       0x00, /* 73 */
-       0x00, /* 74 */
-       0x00, /* 75 */
-       0x00, /* 76 */
-       0x00, /* 77 */
-       0x00, /* 78 */
-       0x00, /* 79 */
-       0x00, /* 7A */
-       0x00, /* 7B */
-       0x00, /* 7C */
-       0x00, /* 7D */
-       0x00, /* 7E */
-       0x00, /* 7F */
-       0x00, /* 80 */
-       0x00, /* 81 */
-       0x00, /* 82 */
-       0x00, /* 83 */
-       0x00, /* 84 */
-       0x00, /* 85 */
-       0x00, /* 86 */
-       0x00, /* 87 */
-       0x00, /* 88 */
-       0x00, /* 89 */
-       0x00, /* 8A */
-       0x00, /* 8B */
-       0x00, /* 8C */
-       0x00, /* 8D */
-       0x00, /* 8E */
-       0x00, /* 8F */
-       0x00, /* 90 */
-       0x00, /* 91 */
-       0x30, /* 92 */
-       0xF0, /* 93 */
-       0x00, /* 94 */
-       0x00, /* 95 */
-       0x3F, /* 96 */
-       0x00, /* 97 */
-       0x00, /* 98 */
-       0x00, /* 99 */
-       0x00, /* 9A */
-       0x00, /* 9B */
-       0x00, /* 9C */
-       0x00, /* 9D */
-       0x00, /* 9E */
-       0x00, /* 9F */
-       0x00, /* A0 */
-       0x00, /* A1 */
-       0x00, /* A2 */
-       0x00, /* A3 */
-       0x00, /* A4 */
-       0x00, /* A5 */
-       0x00, /* A6 */
-       0x00, /* A7 */
-       0x00, /* A8 */
-       0x00, /* A9 */
-       0x00, /* AA */
-       0x00, /* AB */
-       0x00, /* AC */
-       0x00, /* AD */
-       0x00, /* AE */
-       0x00, /* AF */
-       0x00, /* B0 */
-       0x00, /* B1 */
-       0x00, /* B2 */
-       0x00, /* B3 */
-       0x00, /* B4 */
-       0x00, /* B5 */
-       0x00, /* B6 */
-       0x00, /* B7 */
-       0x00, /* B8 */
-       0x00, /* B9 */
-       0x00, /* BA */
-       0x00, /* BB */
-       0x00, /* BC */
-       0x00, /* BD */
-       0x00, /* BE */
-       0x00, /* BF */
-       0x00, /* C0 */
-       0x00, /* C1 */
-       0x00, /* C2 */
-       0x00, /* C3 */
-       0x00, /* C4 */
-       0x00, /* C5 */
-       0x00, /* C6 */
-       0x00, /* C7 */
-       0x00, /* C8 */
-       0x00, /* C9 */
-       0x00, /* CA */
-       0x00, /* CB */
-       0x00, /* CC */
-       0x00, /* CD */
-       0x00, /* CE */
-       0x00, /* CF */
-       0x00, /* D0 */
-       0x00, /* D1 */
-       0x00, /* D2 */
-       0x00, /* D3 */
-       0x00, /* D4 */
-       0x00, /* D5 */
-       0x00, /* D6 */
-       0x00, /* D7 */
-       0x00, /* D8 */
-       0x00, /* D9 */
-       0x00, /* DA */
-       0x00, /* DB */
-       0x00, /* DC */
-       0x00, /* DD */
-       0x00, /* DE */
-       0x00, /* DF */
-       0x00, /* E0 */
-       0x00, /* E1 */
-       0x00, /* E2 */
-       0x00, /* E3 */
-       0x00, /* E4 */
-       0x00, /* E5 */
-       0x00, /* E6 */
-       0x00, /* E7 */
-       0x00, /* E8 */
-       0x00, /* E9 */
-       0x00, /* EA */
-       0x00, /* EB */
-       0x00, /* EC */
-       0x00, /* ED */
-       0x00, /* EE */
-       0x00, /* EF */
-       0x00, /* F0 */
-       0x00, /* F1 */
-       0x00, /* F2 */
-       0x00, /* F3 */
-       0x00, /* F4 */
-       0x00, /* F5 */
-       0x00, /* F6 */
-       0x00, /* F7 */
-       0x00, /* F8 */
-       0x00, /* F9 */
-       0x00, /* FA */
-       0x00, /* FB */
-       0x00, /* FC */
-       0x00, /* FD */
-       0x00, /* FE */
-       0x00, /* FF */
+static const struct reg_default max98095_reg_def[] = {
+       {  0xf, 0x00 }, /* 0F */
+       { 0x10, 0x00 }, /* 10 */
+       { 0x11, 0x00 }, /* 11 */
+       { 0x12, 0x00 }, /* 12 */
+       { 0x13, 0x00 }, /* 13 */
+       { 0x14, 0x00 }, /* 14 */
+       { 0x15, 0x00 }, /* 15 */
+       { 0x16, 0x00 }, /* 16 */
+       { 0x17, 0x00 }, /* 17 */
+       { 0x18, 0x00 }, /* 18 */
+       { 0x19, 0x00 }, /* 19 */
+       { 0x1a, 0x00 }, /* 1A */
+       { 0x1b, 0x00 }, /* 1B */
+       { 0x1c, 0x00 }, /* 1C */
+       { 0x1d, 0x00 }, /* 1D */
+       { 0x1e, 0x00 }, /* 1E */
+       { 0x1f, 0x00 }, /* 1F */
+       { 0x20, 0x00 }, /* 20 */
+       { 0x21, 0x00 }, /* 21 */
+       { 0x22, 0x00 }, /* 22 */
+       { 0x23, 0x00 }, /* 23 */
+       { 0x24, 0x00 }, /* 24 */
+       { 0x25, 0x00 }, /* 25 */
+       { 0x26, 0x00 }, /* 26 */
+       { 0x27, 0x00 }, /* 27 */
+       { 0x28, 0x00 }, /* 28 */
+       { 0x29, 0x00 }, /* 29 */
+       { 0x2a, 0x00 }, /* 2A */
+       { 0x2b, 0x00 }, /* 2B */
+       { 0x2c, 0x00 }, /* 2C */
+       { 0x2d, 0x00 }, /* 2D */
+       { 0x2e, 0x00 }, /* 2E */
+       { 0x2f, 0x00 }, /* 2F */
+       { 0x30, 0x00 }, /* 30 */
+       { 0x31, 0x00 }, /* 31 */
+       { 0x32, 0x00 }, /* 32 */
+       { 0x33, 0x00 }, /* 33 */
+       { 0x34, 0x00 }, /* 34 */
+       { 0x35, 0x00 }, /* 35 */
+       { 0x36, 0x00 }, /* 36 */
+       { 0x37, 0x00 }, /* 37 */
+       { 0x38, 0x00 }, /* 38 */
+       { 0x39, 0x00 }, /* 39 */
+       { 0x3a, 0x00 }, /* 3A */
+       { 0x3b, 0x00 }, /* 3B */
+       { 0x3c, 0x00 }, /* 3C */
+       { 0x3d, 0x00 }, /* 3D */
+       { 0x3e, 0x00 }, /* 3E */
+       { 0x3f, 0x00 }, /* 3F */
+       { 0x40, 0x00 }, /* 40 */
+       { 0x41, 0x00 }, /* 41 */
+       { 0x42, 0x00 }, /* 42 */
+       { 0x43, 0x00 }, /* 43 */
+       { 0x44, 0x00 }, /* 44 */
+       { 0x45, 0x00 }, /* 45 */
+       { 0x46, 0x00 }, /* 46 */
+       { 0x47, 0x00 }, /* 47 */
+       { 0x48, 0x00 }, /* 48 */
+       { 0x49, 0x00 }, /* 49 */
+       { 0x4a, 0x00 }, /* 4A */
+       { 0x4b, 0x00 }, /* 4B */
+       { 0x4c, 0x00 }, /* 4C */
+       { 0x4d, 0x00 }, /* 4D */
+       { 0x4e, 0x00 }, /* 4E */
+       { 0x4f, 0x00 }, /* 4F */
+       { 0x50, 0x00 }, /* 50 */
+       { 0x51, 0x00 }, /* 51 */
+       { 0x52, 0x00 }, /* 52 */
+       { 0x53, 0x00 }, /* 53 */
+       { 0x54, 0x00 }, /* 54 */
+       { 0x55, 0x00 }, /* 55 */
+       { 0x56, 0x00 }, /* 56 */
+       { 0x57, 0x00 }, /* 57 */
+       { 0x58, 0x00 }, /* 58 */
+       { 0x59, 0x00 }, /* 59 */
+       { 0x5a, 0x00 }, /* 5A */
+       { 0x5b, 0x00 }, /* 5B */
+       { 0x5c, 0x00 }, /* 5C */
+       { 0x5d, 0x00 }, /* 5D */
+       { 0x5e, 0x00 }, /* 5E */
+       { 0x5f, 0x00 }, /* 5F */
+       { 0x60, 0x00 }, /* 60 */
+       { 0x61, 0x00 }, /* 61 */
+       { 0x62, 0x00 }, /* 62 */
+       { 0x63, 0x00 }, /* 63 */
+       { 0x64, 0x00 }, /* 64 */
+       { 0x65, 0x00 }, /* 65 */
+       { 0x66, 0x00 }, /* 66 */
+       { 0x67, 0x00 }, /* 67 */
+       { 0x68, 0x00 }, /* 68 */
+       { 0x69, 0x00 }, /* 69 */
+       { 0x6a, 0x00 }, /* 6A */
+       { 0x6b, 0x00 }, /* 6B */
+       { 0x6c, 0x00 }, /* 6C */
+       { 0x6d, 0x00 }, /* 6D */
+       { 0x6e, 0x00 }, /* 6E */
+       { 0x6f, 0x00 }, /* 6F */
+       { 0x70, 0x00 }, /* 70 */
+       { 0x71, 0x00 }, /* 71 */
+       { 0x72, 0x00 }, /* 72 */
+       { 0x73, 0x00 }, /* 73 */
+       { 0x74, 0x00 }, /* 74 */
+       { 0x75, 0x00 }, /* 75 */
+       { 0x76, 0x00 }, /* 76 */
+       { 0x77, 0x00 }, /* 77 */
+       { 0x78, 0x00 }, /* 78 */
+       { 0x79, 0x00 }, /* 79 */
+       { 0x7a, 0x00 }, /* 7A */
+       { 0x7b, 0x00 }, /* 7B */
+       { 0x7c, 0x00 }, /* 7C */
+       { 0x7d, 0x00 }, /* 7D */
+       { 0x7e, 0x00 }, /* 7E */
+       { 0x7f, 0x00 }, /* 7F */
+       { 0x80, 0x00 }, /* 80 */
+       { 0x81, 0x00 }, /* 81 */
+       { 0x82, 0x00 }, /* 82 */
+       { 0x83, 0x00 }, /* 83 */
+       { 0x84, 0x00 }, /* 84 */
+       { 0x85, 0x00 }, /* 85 */
+       { 0x86, 0x00 }, /* 86 */
+       { 0x87, 0x00 }, /* 87 */
+       { 0x88, 0x00 }, /* 88 */
+       { 0x89, 0x00 }, /* 89 */
+       { 0x8a, 0x00 }, /* 8A */
+       { 0x8b, 0x00 }, /* 8B */
+       { 0x8c, 0x00 }, /* 8C */
+       { 0x8d, 0x00 }, /* 8D */
+       { 0x8e, 0x00 }, /* 8E */
+       { 0x8f, 0x00 }, /* 8F */
+       { 0x90, 0x00 }, /* 90 */
+       { 0x91, 0x00 }, /* 91 */
+       { 0x92, 0x30 }, /* 92 */
+       { 0x93, 0xF0 }, /* 93 */
+       { 0x94, 0x00 }, /* 94 */
+       { 0x95, 0x00 }, /* 95 */
+       { 0x96, 0x3F }, /* 96 */
+       { 0x97, 0x00 }, /* 97 */
+       { 0xff, 0x00 }, /* FF */
 };
 
 static struct {
@@ -577,14 +460,14 @@ static struct {
        { 0xFF, 0x00 }, /* FF */
 };
 
-static int max98095_readable(struct snd_soc_codec *codec, unsigned int reg)
+static bool max98095_readable(struct device *dev, unsigned int reg)
 {
        if (reg >= M98095_REG_CNT)
                return 0;
        return max98095_access[reg].readable != 0;
 }
 
-static int max98095_volatile(struct snd_soc_codec *codec, unsigned int reg)
+static bool max98095_volatile(struct device *dev, unsigned int reg)
 {
        if (reg > M98095_REG_MAX_CACHED)
                return 1;
@@ -611,22 +494,18 @@ static int max98095_volatile(struct snd_soc_codec *codec, unsigned int reg)
        return 0;
 }
 
-/*
- * Filter coefficients are in a separate register segment
- * and they share the address space of the normal registers.
- * The coefficient registers do not need or share the cache.
- */
-static int max98095_hw_write(struct snd_soc_codec *codec, unsigned int reg,
-                            unsigned int value)
-{
-       int ret;
+static const struct regmap_config max98095_regmap = {
+       .reg_bits = 8,
+       .val_bits = 8,
 
-       codec->cache_bypass = 1;
-       ret = snd_soc_write(codec, reg, value);
-       codec->cache_bypass = 0;
+       .reg_defaults = max98095_reg_def,
+       .num_reg_defaults = ARRAY_SIZE(max98095_reg_def),
+       .max_register = M98095_0FF_REV_ID,
+       .cache_type = REGCACHE_RBTREE,
 
-       return ret ? -EIO : 0;
-}
+       .readable_reg = max98095_readable,
+       .volatile_reg = max98095_volatile,
+};
 
 /*
  * Load equalizer DSP coefficient configurations registers
@@ -648,8 +527,8 @@ static void m98095_eq_band(struct snd_soc_codec *codec, unsigned int dai,
 
        /* Step through the registers and coefs */
        for (i = 0; i < M98095_COEFS_PER_BAND; i++) {
-               max98095_hw_write(codec, eq_reg++, M98095_BYTE1(coefs[i]));
-               max98095_hw_write(codec, eq_reg++, M98095_BYTE0(coefs[i]));
+               snd_soc_write(codec, eq_reg++, M98095_BYTE1(coefs[i]));
+               snd_soc_write(codec, eq_reg++, M98095_BYTE0(coefs[i]));
        }
 }
 
@@ -673,8 +552,8 @@ static void m98095_biquad_band(struct snd_soc_codec *codec, unsigned int dai,
 
        /* Step through the registers and coefs */
        for (i = 0; i < M98095_COEFS_PER_BAND; i++) {
-               max98095_hw_write(codec, bq_reg++, M98095_BYTE1(coefs[i]));
-               max98095_hw_write(codec, bq_reg++, M98095_BYTE0(coefs[i]));
+               snd_soc_write(codec, bq_reg++, M98095_BYTE1(coefs[i]));
+               snd_soc_write(codec, bq_reg++, M98095_BYTE0(coefs[i]));
        }
 }
 
@@ -1285,14 +1164,6 @@ static const struct snd_soc_dapm_route max98095_audio_map[] = {
        {"MIC2 Input", NULL, "MIC2"},
 };
 
-static int max98095_add_widgets(struct snd_soc_codec *codec)
-{
-       snd_soc_add_codec_controls(codec, max98095_snd_controls,
-                            ARRAY_SIZE(max98095_snd_controls));
-
-       return 0;
-}
-
 /* codec mclk clock divider coefficients */
 static const struct {
        u32 rate;
@@ -1748,6 +1619,7 @@ static int max98095_dai3_set_fmt(struct snd_soc_dai *codec_dai,
 static int max98095_set_bias_level(struct snd_soc_codec *codec,
                                   enum snd_soc_bias_level level)
 {
+       struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
        int ret;
 
        switch (level) {
@@ -1759,7 +1631,7 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec,
 
        case SND_SOC_BIAS_STANDBY:
                if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
-                       ret = snd_soc_cache_sync(codec);
+                       ret = regcache_sync(max98095->regmap);
 
                        if (ret != 0) {
                                dev_err(codec->dev, "Failed to sync cache: %d\n", ret);
@@ -1774,7 +1646,7 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec,
        case SND_SOC_BIAS_OFF:
                snd_soc_update_bits(codec, M98095_090_PWR_EN_IN,
                                M98095_MBEN, 0);
-               codec->cache_sync = 1;
+               regcache_mark_dirty(max98095->regmap);
                break;
        }
        codec->dapm.bias_level = level;
@@ -2341,7 +2213,7 @@ static int max98095_reset(struct snd_soc_codec *codec)
        /* Reset to hardware default for registers, as there is not
         * a soft reset hardware control register */
        for (i = M98095_010_HOST_INT_CFG; i < M98095_REG_MAX_CACHED; i++) {
-               ret = snd_soc_write(codec, i, max98095_reg_def[i]);
+               ret = snd_soc_write(codec, i, snd_soc_read(codec, i));
                if (ret < 0) {
                        dev_err(codec->dev, "Failed to reset: %d\n", ret);
                        return ret;
@@ -2358,7 +2230,7 @@ static int max98095_probe(struct snd_soc_codec *codec)
        struct i2c_client *client;
        int ret = 0;
 
-       ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
+       ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
        if (ret != 0) {
                dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
                return ret;
@@ -2447,8 +2319,6 @@ static int max98095_probe(struct snd_soc_codec *codec)
        snd_soc_update_bits(codec, M98095_097_PWR_SYS, M98095_SHDNRUN,
                M98095_SHDNRUN);
 
-       max98095_add_widgets(codec);
-
        return 0;
 
 err_irq:
@@ -2480,11 +2350,8 @@ static struct snd_soc_codec_driver soc_codec_dev_max98095 = {
        .suspend = max98095_suspend,
        .resume  = max98095_resume,
        .set_bias_level = max98095_set_bias_level,
-       .reg_cache_size = ARRAY_SIZE(max98095_reg_def),
-       .reg_word_size = sizeof(u8),
-       .reg_cache_default = max98095_reg_def,
-       .readable_register = max98095_readable,
-       .volatile_register = max98095_volatile,
+       .controls = max98095_snd_controls,
+       .num_controls = ARRAY_SIZE(max98095_snd_controls),
        .dapm_widgets     = max98095_dapm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(max98095_dapm_widgets),
        .dapm_routes     = max98095_audio_map,
@@ -2502,6 +2369,13 @@ static int max98095_i2c_probe(struct i2c_client *i2c,
        if (max98095 == NULL)
                return -ENOMEM;
 
+       max98095->regmap = devm_regmap_init_i2c(i2c, &max98095_regmap);
+       if (IS_ERR(max98095->regmap)) {
+               ret = PTR_ERR(max98095->regmap);
+               dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
+               return ret;
+       }
+
        max98095->devtype = id->driver_data;
        i2c_set_clientdata(i2c, max98095);
        max98095->pdata = i2c->dev.platform_data;
index 58c38a5b481ccb7658a8a6a285d5874d13659d50..c5dd61785f8d6318097ae3d0878f881d93e78c29 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/regmap.h>
 #include <linux/slab.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include "max9850.h"
 
 struct max9850_priv {
+       struct regmap *regmap;
        unsigned int sysclk;
 };
 
 /* max9850 register cache */
-static const u8 max9850_reg[MAX9850_CACHEREGNUM] = {
-       0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+static const struct reg_default max9850_reg[] = {
+       {  2, 0x0c },
+       {  3, 0x00 },
+       {  4, 0x00 },
+       {  5, 0x00 },
+       {  6, 0x00 },
+       {  7, 0x00 },
+       {  8, 0x00 },
+       {  9, 0x00 },
+       { 10, 0x00 },
 };
 
 /* these registers are not used at the moment but provided for the sake of
  * completeness */
-static int max9850_volatile_register(struct snd_soc_codec *codec,
-               unsigned int reg)
+static bool max9850_volatile_register(struct device *dev, unsigned int reg)
 {
        switch (reg) {
        case MAX9850_STATUSA:
@@ -49,6 +58,15 @@ static int max9850_volatile_register(struct snd_soc_codec *codec,
        }
 }
 
+static const struct regmap_config max9850_regmap = {
+       .reg_bits = 8,
+       .val_bits = 8,
+
+       .max_register = MAX9850_DIGITAL_AUDIO,
+       .volatile_reg = max9850_volatile_register,
+       .cache_type = REGCACHE_RBTREE,
+};
+
 static const unsigned int max9850_tlv[] = {
        TLV_DB_RANGE_HEAD(4),
        0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0),
@@ -225,6 +243,7 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 static int max9850_set_bias_level(struct snd_soc_codec *codec,
                                  enum snd_soc_bias_level level)
 {
+       struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec);
        int ret;
 
        switch (level) {
@@ -234,7 +253,7 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec,
                break;
        case SND_SOC_BIAS_STANDBY:
                if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
-                       ret = snd_soc_cache_sync(codec);
+                       ret = regcache_sync(max9850->regmap);
                        if (ret) {
                                dev_err(codec->dev,
                                        "Failed to sync cache: %d\n", ret);
@@ -295,7 +314,7 @@ static int max9850_probe(struct snd_soc_codec *codec)
 {
        int ret;
 
-       ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
+       ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
        if (ret < 0) {
                dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
                return ret;
@@ -316,10 +335,6 @@ static struct snd_soc_codec_driver soc_codec_dev_max9850 = {
        .suspend =      max9850_suspend,
        .resume =       max9850_resume,
        .set_bias_level = max9850_set_bias_level,
-       .reg_cache_size = ARRAY_SIZE(max9850_reg),
-       .reg_word_size = sizeof(u8),
-       .reg_cache_default = max9850_reg,
-       .volatile_register = max9850_volatile_register,
 
        .controls = max9850_controls,
        .num_controls = ARRAY_SIZE(max9850_controls),
@@ -340,6 +355,10 @@ static int max9850_i2c_probe(struct i2c_client *i2c,
        if (max9850 == NULL)
                return -ENOMEM;
 
+       max9850->regmap = devm_regmap_init_i2c(i2c, &max9850_regmap);
+       if (IS_ERR(max9850->regmap))
+               return PTR_ERR(max9850->regmap);
+
        i2c_set_clientdata(i2c, max9850);
 
        ret = snd_soc_register_codec(&i2c->dev,
index ea141e1d6f280733fdc832f7b5e2d054f2e8fff4..bae60164c7b7355408ab77676daa680bcb5946b0 100644 (file)
 #include <sound/soc.h>
 #include <sound/initval.h>
 #include <sound/soc-dapm.h>
+#include <linux/regmap.h>
 
 #include "mc13783.h"
 
-#define MC13783_AUDIO_RX0      36
-#define MC13783_AUDIO_RX1      37
-#define MC13783_AUDIO_TX       38
-#define MC13783_SSI_NETWORK    39
-#define MC13783_AUDIO_CODEC    40
-#define MC13783_AUDIO_DAC      41
-
 #define AUDIO_RX0_ALSPEN               (1 << 5)
 #define AUDIO_RX0_ALSPSEL              (1 << 7)
 #define AUDIO_RX0_ADDCDC               (1 << 21)
 
 struct mc13783_priv {
        struct mc13xxx *mc13xxx;
+       struct regmap *regmap;
 
        enum mc13783_ssi_port adc_ssi_port;
        enum mc13783_ssi_port dac_ssi_port;
 };
 
-static unsigned int mc13783_read(struct snd_soc_codec *codec,
-       unsigned int reg)
-{
-       struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec);
-       unsigned int value = 0;
-
-       mc13xxx_lock(priv->mc13xxx);
-
-       mc13xxx_reg_read(priv->mc13xxx, reg, &value);
-
-       mc13xxx_unlock(priv->mc13xxx);
-
-       return value;
-}
-
-static int mc13783_write(struct snd_soc_codec *codec,
-       unsigned int reg, unsigned int value)
-{
-       struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec);
-       int ret;
-
-       mc13xxx_lock(priv->mc13xxx);
-
-       ret = mc13xxx_reg_write(priv->mc13xxx, reg, value);
-
-       /* include errata fix for spi audio problems */
-       if (reg == MC13783_AUDIO_CODEC || reg == MC13783_AUDIO_DAC)
-               ret = mc13xxx_reg_write(priv->mc13xxx, reg, value);
-
-       mc13xxx_unlock(priv->mc13xxx);
-
-       return ret;
-}
-
 /* Mapping between sample rates and register value */
 static unsigned int mc13783_rates[] = {
        8000, 11025, 12000, 16000,
@@ -382,7 +343,7 @@ static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai,
                break;
        default:
                return -EINVAL;
-       };
+       }
 
        snd_soc_update_bits(codec, MC13783_SSI_NETWORK, mask, val);
 
@@ -466,6 +427,29 @@ static const struct snd_kcontrol_new right_input_mux =
 static const struct snd_kcontrol_new samp_ctl =
        SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 3, 1, 0);
 
+static const char * const speaker_amp_source_text[] = {
+       "CODEC", "Right"
+};
+static const SOC_ENUM_SINGLE_DECL(speaker_amp_source, MC13783_AUDIO_RX0, 4,
+                                 speaker_amp_source_text);
+static const struct snd_kcontrol_new speaker_amp_source_mux =
+       SOC_DAPM_ENUM("Speaker Amp Source MUX", speaker_amp_source);
+
+static const char * const headset_amp_source_text[] = {
+       "CODEC", "Mixer"
+};
+
+static const SOC_ENUM_SINGLE_DECL(headset_amp_source, MC13783_AUDIO_RX0, 11,
+                                 headset_amp_source_text);
+static const struct snd_kcontrol_new headset_amp_source_mux =
+       SOC_DAPM_ENUM("Headset Amp Source MUX", headset_amp_source);
+
+static const struct snd_kcontrol_new cdcout_ctl =
+       SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 18, 1, 0);
+
+static const struct snd_kcontrol_new adc_bypass_ctl =
+       SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_CODEC, 16, 1, 0);
+
 static const struct snd_kcontrol_new lamp_ctl =
        SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 5, 1, 0);
 
@@ -503,12 +487,22 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = {
        SND_SOC_DAPM_VIRT_MUX("PGA Right Input Mux", SND_SOC_NOPM, 0, 0,
                              &right_input_mux),
 
+       SND_SOC_DAPM_MUX("Speaker Amp Source MUX", SND_SOC_NOPM, 0, 0,
+                        &speaker_amp_source_mux),
+
+       SND_SOC_DAPM_MUX("Headset Amp Source MUX", SND_SOC_NOPM, 0, 0,
+                        &headset_amp_source_mux),
+
        SND_SOC_DAPM_PGA("PGA Left Input", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_PGA("PGA Right Input", SND_SOC_NOPM, 0, 0, NULL, 0),
 
        SND_SOC_DAPM_ADC("ADC", "Capture", MC13783_AUDIO_CODEC, 11, 0),
        SND_SOC_DAPM_SUPPLY("ADC_Reset", MC13783_AUDIO_CODEC, 15, 0, NULL, 0),
 
+       SND_SOC_DAPM_PGA("Voice CODEC PGA", MC13783_AUDIO_RX1, 0, 0, NULL, 0),
+       SND_SOC_DAPM_SWITCH("Voice CODEC Bypass", MC13783_AUDIO_CODEC, 16, 0,
+                       &adc_bypass_ctl),
+
 /* Output */
        SND_SOC_DAPM_SUPPLY("DAC_E", MC13783_AUDIO_DAC, 11, 0, NULL, 0),
        SND_SOC_DAPM_SUPPLY("DAC_Reset", MC13783_AUDIO_DAC, 15, 0, NULL, 0),
@@ -516,10 +510,15 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = {
        SND_SOC_DAPM_OUTPUT("RXOUTR"),
        SND_SOC_DAPM_OUTPUT("HSL"),
        SND_SOC_DAPM_OUTPUT("HSR"),
+       SND_SOC_DAPM_OUTPUT("LSPL"),
        SND_SOC_DAPM_OUTPUT("LSP"),
        SND_SOC_DAPM_OUTPUT("SP"),
+       SND_SOC_DAPM_OUTPUT("CDCOUT"),
 
-       SND_SOC_DAPM_SWITCH("Speaker Amp", MC13783_AUDIO_RX0, 3, 0, &samp_ctl),
+       SND_SOC_DAPM_SWITCH("CDCOUT Switch", MC13783_AUDIO_RX0, 18, 0,
+                       &cdcout_ctl),
+       SND_SOC_DAPM_SWITCH("Speaker Amp Switch", MC13783_AUDIO_RX0, 3, 0,
+                       &samp_ctl),
        SND_SOC_DAPM_SWITCH("Loudspeaker Amp", SND_SOC_NOPM, 0, 0, &lamp_ctl),
        SND_SOC_DAPM_SWITCH("Headset Amp Left", MC13783_AUDIO_RX0, 10, 0,
                        &hlamp_ctl),
@@ -554,20 +553,28 @@ static struct snd_soc_dapm_route mc13783_routes[] = {
        { "ADC", NULL, "PGA Right Input"},
        { "ADC", NULL, "ADC_Reset"},
 
+       { "Voice CODEC PGA", "Voice CODEC Bypass", "ADC" },
+
+       { "Speaker Amp Source MUX", "CODEC", "Voice CODEC PGA"},
+       { "Speaker Amp Source MUX", "Right", "DAC PGA"},
+
+       { "Headset Amp Source MUX", "CODEC", "Voice CODEC PGA"},
+       { "Headset Amp Source MUX", "Mixer", "DAC PGA"},
+
 /* Output */
        { "HSL", NULL, "Headset Amp Left" },
        { "HSR", NULL, "Headset Amp Right"},
        { "RXOUTL", NULL, "Line out Amp Left"},
        { "RXOUTR", NULL, "Line out Amp Right"},
-       { "SP", NULL, "Speaker Amp"},
-       { "Speaker Amp", NULL, "DAC PGA"},
-       { "LSP", NULL, "DAC PGA"},
-       { "Headset Amp Left", NULL, "DAC PGA"},
-       { "Headset Amp Right", NULL, "DAC PGA"},
+       { "SP", "Speaker Amp Switch", "Speaker Amp Source MUX"},
+       { "LSP", "Loudspeaker Amp", "Speaker Amp Source MUX"},
+       { "HSL", "Headset Amp Left", "Headset Amp Source MUX"},
+       { "HSR", "Headset Amp Right", "Headset Amp Source MUX"},
        { "Line out Amp Left", NULL, "DAC PGA"},
        { "Line out Amp Right", NULL, "DAC PGA"},
        { "DAC PGA", NULL, "DAC"},
        { "DAC", NULL, "DAC_E"},
+       { "CDCOUT", "CDCOUT Switch", "Voice CODEC PGA"},
 };
 
 static const char * const mc13783_3d_mixer[] = {"Stereo", "Phase Mix",
@@ -580,15 +587,39 @@ static const struct soc_enum mc13783_enum_3d_mixer =
 static struct snd_kcontrol_new mc13783_control_list[] = {
        SOC_SINGLE("Loudspeaker enable", MC13783_AUDIO_RX0, 5, 1, 0),
        SOC_SINGLE("PCM Playback Volume", MC13783_AUDIO_RX1, 6, 15, 0),
+       SOC_SINGLE("PCM Playback Switch", MC13783_AUDIO_RX1, 5, 1, 0),
        SOC_DOUBLE("PCM Capture Volume", MC13783_AUDIO_TX, 19, 14, 31, 0),
        SOC_ENUM("3D Control", mc13783_enum_3d_mixer),
+
+       SOC_SINGLE("CDCOUT Switch", MC13783_AUDIO_RX0, 18, 1, 0),
+       SOC_SINGLE("Earpiece Amp Switch", MC13783_AUDIO_RX0, 3, 1, 0),
+       SOC_DOUBLE("Headset Amp Switch", MC13783_AUDIO_RX0, 10, 9, 1, 0),
+       SOC_DOUBLE("Line out Amp Switch", MC13783_AUDIO_RX0, 16, 15, 1, 0),
+
+       SOC_SINGLE("PCM Capture Mixin Switch", MC13783_AUDIO_RX0, 22, 1, 0),
+       SOC_SINGLE("Line in Capture Mixin Switch", MC13783_AUDIO_RX0, 23, 1, 0),
+
+       SOC_SINGLE("CODEC Capture Volume", MC13783_AUDIO_RX1, 1, 15, 0),
+       SOC_SINGLE("CODEC Capture Mixin Switch", MC13783_AUDIO_RX0, 21, 1, 0),
+
+       SOC_SINGLE("Line in Capture Volume", MC13783_AUDIO_RX1, 12, 15, 0),
+       SOC_SINGLE("Line in Capture Switch", MC13783_AUDIO_RX1, 10, 1, 0),
+
+       SOC_SINGLE("MC1 Capture Bias Switch", MC13783_AUDIO_TX, 0, 1, 0),
+       SOC_SINGLE("MC2 Capture Bias Switch", MC13783_AUDIO_TX, 1, 1, 0),
 };
 
 static int mc13783_probe(struct snd_soc_codec *codec)
 {
        struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec);
+       int ret;
 
-       mc13xxx_lock(priv->mc13xxx);
+       codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
+       ret = snd_soc_codec_set_cache_io(codec, 8, 24, SND_SOC_REGMAP);
+       if (ret != 0) {
+               dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
+               return ret;
+       }
 
        /* these are the reset values */
        mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893);
@@ -612,8 +643,6 @@ static int mc13783_probe(struct snd_soc_codec *codec)
                mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC,
                                0, AUDIO_SSI_SEL);
 
-       mc13xxx_unlock(priv->mc13xxx);
-
        return 0;
 }
 
@@ -621,13 +650,9 @@ static int mc13783_remove(struct snd_soc_codec *codec)
 {
        struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec);
 
-       mc13xxx_lock(priv->mc13xxx);
-
        /* Make sure VAUDIOON is off */
        mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_RX0, 0x3, 0);
 
-       mc13xxx_unlock(priv->mc13xxx);
-
        return 0;
 }
 
@@ -717,8 +742,6 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = {
 static struct snd_soc_codec_driver soc_codec_dev_mc13783 = {
        .probe          = mc13783_probe,
        .remove         = mc13783_remove,
-       .read           = mc13783_read,
-       .write          = mc13783_write,
        .controls       = mc13783_control_list,
        .num_controls   = ARRAY_SIZE(mc13783_control_list),
        .dapm_widgets   = mc13783_dapm_widgets,
index c91eba504f92bc053dd2a51b8f62c7bff6bcc2d6..73f9c3630e2c8e33a56b089fa3a0d5f16e418dd3 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/gpio.h>
 #include <linux/i2c.h>
 #include <linux/regmap.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <sound/pcm.h>
index 7613181123fe393042643847f4e2b5dbf4c89285..7146653a8e165c942f7107c5ff305dea785578d9 100644 (file)
@@ -28,6 +28,7 @@
 #include <sound/initval.h>
 #include <sound/soc.h>
 #include <sound/tlv.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 
 #include "pcm1792a.h"
index c26a8f814b1865269b3869acf60c8c7f7a20349c..4d041d376f3191555503d249a7f0c71a375c729a 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/acpi.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -926,7 +927,7 @@ static int rt5640_set_dmic2_event(struct snd_soc_dapm_widget *w,
        return 0;
 }
 
-void hp_amp_power_on(struct snd_soc_codec *codec)
+static void hp_amp_power_on(struct snd_soc_codec *codec)
 {
        struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
 
@@ -1609,7 +1610,8 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream,
        rt5640->lrck[dai->id] = params_rate(params);
        pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]);
        if (pre_div < 0) {
-               dev_err(codec->dev, "Unsupported clock setting\n");
+               dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n",
+                       rt5640->lrck[dai->id], dai->id);
                return -EINVAL;
        }
        frame_size = snd_soc_params_to_frame_size(params);
@@ -1977,13 +1979,20 @@ static int rt5640_suspend(struct snd_soc_codec *codec)
        rt5640_reset(codec);
        regcache_cache_only(rt5640->regmap, true);
        regcache_mark_dirty(rt5640->regmap);
+       if (gpio_is_valid(rt5640->pdata.ldo1_en))
+               gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 0);
 
        return 0;
 }
 
 static int rt5640_resume(struct snd_soc_codec *codec)
 {
-       rt5640_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+       struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
+
+       if (gpio_is_valid(rt5640->pdata.ldo1_en)) {
+               gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 1);
+               msleep(400);
+       }
 
        return 0;
 }
@@ -2080,6 +2089,14 @@ static const struct i2c_device_id rt5640_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id);
 
+#ifdef CONFIG_ACPI
+static struct acpi_device_id rt5640_acpi_match[] = {
+       { "INT33CA", 0 },
+       { },
+};
+MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match);
+#endif
+
 static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np)
 {
        rt5640->pdata.in1_diff = of_property_read_bool(np,
@@ -2199,6 +2216,7 @@ static struct i2c_driver rt5640_i2c_driver = {
        .driver = {
                .name = "rt5640",
                .owner = THIS_MODULE,
+               .acpi_match_table = ACPI_PTR(rt5640_acpi_match),
        },
        .probe = rt5640_i2c_probe,
        .remove   = rt5640_i2c_remove,
index 38f3b105c17dc2da0809c903190dd37644f2508d..52e7cb08434bd281354c4a34f520f16c38b0446f 100644 (file)
@@ -60,48 +60,6 @@ enum si476x_pcm_format {
        SI476X_PCM_FORMAT_S24_LE        = 6,
 };
 
-static unsigned int si476x_codec_read(struct snd_soc_codec *codec,
-                                     unsigned int reg)
-{
-       int err;
-       unsigned int val;
-       struct si476x_core *core = codec->control_data;
-
-       si476x_core_lock(core);
-       if (!si476x_core_is_powered_up(core))
-               regcache_cache_only(core->regmap, true);
-
-       err = regmap_read(core->regmap, reg, &val);
-
-       if (!si476x_core_is_powered_up(core))
-               regcache_cache_only(core->regmap, false);
-       si476x_core_unlock(core);
-
-       if (err < 0)
-               return err;
-
-       return val;
-}
-
-static int si476x_codec_write(struct snd_soc_codec *codec,
-                             unsigned int reg, unsigned int val)
-{
-       int err;
-       struct si476x_core *core = codec->control_data;
-
-       si476x_core_lock(core);
-       if (!si476x_core_is_powered_up(core))
-               regcache_cache_only(core->regmap, true);
-
-       err = regmap_write(core->regmap, reg, val);
-
-       if (!si476x_core_is_powered_up(core))
-               regcache_cache_only(core->regmap, false);
-       si476x_core_unlock(core);
-
-       return err;
-}
-
 static const struct snd_soc_dapm_widget si476x_dapm_widgets[] = {
 SND_SOC_DAPM_OUTPUT("LOUT"),
 SND_SOC_DAPM_OUTPUT("ROUT"),
@@ -115,6 +73,7 @@ static const struct snd_soc_dapm_route si476x_dapm_routes[] = {
 static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
                                    unsigned int fmt)
 {
+       struct si476x_core *core = i2c_mfd_cell_to_core(codec_dai->dev);
        int err;
        u16 format = 0;
 
@@ -178,9 +137,14 @@ static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
                return -EINVAL;
        }
 
+       si476x_core_lock(core);
+
        err = snd_soc_update_bits(codec_dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT,
                                  SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK,
                                  format);
+
+       si476x_core_unlock(core);
+
        if (err < 0) {
                dev_err(codec_dai->codec->dev, "Failed to set output format\n");
                return err;
@@ -193,6 +157,7 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
                                  struct snd_pcm_hw_params *params,
                                  struct snd_soc_dai *dai)
 {
+       struct si476x_core *core = i2c_mfd_cell_to_core(dai->dev);
        int rate, width, err;
 
        rate = params_rate(params);
@@ -218,11 +183,13 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
                return -EINVAL;
        }
 
+       si476x_core_lock(core);
+
        err = snd_soc_write(dai->codec, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE,
                            rate);
        if (err < 0) {
                dev_err(dai->codec->dev, "Failed to set sample rate\n");
-               return err;
+               goto out;
        }
 
        err = snd_soc_update_bits(dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT,
@@ -231,15 +198,18 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
                                  (width << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT));
        if (err < 0) {
                dev_err(dai->codec->dev, "Failed to set output width\n");
-               return err;
+               goto out;
        }
 
-       return 0;
+out:
+       si476x_core_unlock(core);
+
+       return err;
 }
 
 static int si476x_codec_probe(struct snd_soc_codec *codec)
 {
-       codec->control_data = i2c_mfd_cell_to_core(codec->dev);
+       codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
        return 0;
 }
 
@@ -268,8 +238,6 @@ static struct snd_soc_dai_driver si476x_dai = {
 
 static struct snd_soc_codec_driver soc_codec_dev_si476x = {
        .probe  = si476x_codec_probe,
-       .read   = si476x_codec_read,
-       .write  = si476x_codec_write,
        .dapm_widgets = si476x_dapm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets),
        .dapm_routes = si476x_dapm_routes,
index dba26e63844ef901073531bcdb26b1e084bf0a3b..13045f2af4d32a7725961feabc628ac6e088e80c 100644 (file)
@@ -164,30 +164,28 @@ static unsigned int sn95031_get_mic_bias(struct snd_soc_codec *codec)
 }
 /*end - adc helper functions */
 
-static inline unsigned int sn95031_read(struct snd_soc_codec *codec,
-                       unsigned int reg)
+static int sn95031_read(void *ctx, unsigned int reg, unsigned int *val)
 {
        u8 value = 0;
        int ret;
 
        ret = intel_scu_ipc_ioread8(reg, &value);
-       if (ret)
-               pr_err("read of %x failed, err %d\n", reg, ret);
-       return value;
+       if (ret == 0)
+               *val = value;
 
+       return ret;
 }
 
-static inline int sn95031_write(struct snd_soc_codec *codec,
-                       unsigned int reg, unsigned int value)
+static int sn95031_write(void *ctx, unsigned int reg, unsigned int value)
 {
-       int ret;
-
-       ret = intel_scu_ipc_iowrite8(reg, value);
-       if (ret)
-               pr_err("write of %x failed, err %d\n", reg, ret);
-       return ret;
+       return intel_scu_ipc_iowrite8(reg, value);
 }
 
+static const struct regmap_config sn95031_regmap = {
+       .reg_read = sn95031_read,
+       .reg_write = sn95031_write,
+};
+
 static int sn95031_set_vaud_bias(struct snd_soc_codec *codec,
                enum snd_soc_bias_level level)
 {
@@ -827,6 +825,8 @@ static int sn95031_codec_probe(struct snd_soc_codec *codec)
 {
        pr_debug("codec_probe called\n");
 
+       snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
+
        /* PCM interface config
         * This sets the pcm rx slot conguration to max 6 slots
         * for max 4 dais (2 stereo and 2 mono)
@@ -886,8 +886,6 @@ static int sn95031_codec_remove(struct snd_soc_codec *codec)
 static struct snd_soc_codec_driver sn95031_codec = {
        .probe          = sn95031_codec_probe,
        .remove         = sn95031_codec_remove,
-       .read           = sn95031_read,
-       .write          = sn95031_write,
        .set_bias_level = sn95031_set_vaud_bias,
        .idle_bias_off  = true,
        .dapm_widgets   = sn95031_dapm_widgets,
@@ -898,7 +896,14 @@ static struct snd_soc_codec_driver sn95031_codec = {
 
 static int sn95031_device_probe(struct platform_device *pdev)
 {
+       struct regmap *regmap;
+
        pr_debug("codec device probe called for %s\n", dev_name(&pdev->dev));
+
+       regmap = devm_regmap_init(&pdev->dev, NULL, NULL, &sn95031_regmap);
+       if (IS_ERR(regmap))
+               return PTR_ERR(regmap);
+
        return snd_soc_register_codec(&pdev->dev, &sn95031_codec,
                        sn95031_dais, ARRAY_SIZE(sn95031_dais));
 }
index 6d31d88f72040098700a1b57ef3f4d118976a604..a895a5e4bdf207eee6387bc00e8452ae2385233d 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/i2c.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <sound/pcm.h>
@@ -244,6 +245,8 @@ struct tas5086_private {
        unsigned int    mclk, sclk;
        unsigned int    format;
        bool            deemph;
+       unsigned int    charge_period;
+       unsigned int    pwm_start_mid_z;
        /* Current sample rate for de-emphasis control */
        int             rate;
        /* GPIO driving Reset pin, if any */
@@ -429,7 +432,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream,
        default:
                dev_err(codec->dev, "Invalid bit width\n");
                return -EINVAL;
-       };
+       }
 
        ret = regmap_write(priv->regmap, TAS5086_SERIAL_DATA_IF, val);
        if (ret < 0)
@@ -456,6 +459,75 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
        return regmap_write(priv->regmap, TAS5086_SOFT_MUTE, val);
 }
 
+static void tas5086_reset(struct tas5086_private *priv)
+{
+       if (gpio_is_valid(priv->gpio_nreset)) {
+               /* Reset codec - minimum assertion time is 400ns */
+               gpio_direction_output(priv->gpio_nreset, 0);
+               udelay(1);
+               gpio_set_value(priv->gpio_nreset, 1);
+
+               /* Codec needs ~15ms to wake up */
+               msleep(15);
+       }
+}
+
+/* charge period values in microseconds */
+static const int tas5086_charge_period[] = {
+         13000,  16900,   23400,   31200,   41600,   54600,   72800,   96200,
+        130000, 156000,  234000,  312000,  416000,  546000,  728000,  962000,
+       1300000, 169000, 2340000, 3120000, 4160000, 5460000, 7280000, 9620000,
+};
+
+static int tas5086_init(struct device *dev, struct tas5086_private *priv)
+{
+       int ret, i;
+
+       /*
+        * If any of the channels is configured to start in Mid-Z mode,
+        * configure 'part 1' of the PWM starts to use Mid-Z, and tell
+        * all configured mid-z channels to start start under 'part 1'.
+        */
+       if (priv->pwm_start_mid_z)
+               regmap_write(priv->regmap, TAS5086_PWM_START,
+                            TAS5086_PWM_START_MIDZ_FOR_START_1 |
+                               priv->pwm_start_mid_z);
+
+       /* lookup and set split-capacitor charge period */
+       if (priv->charge_period == 0) {
+               regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, 0);
+       } else {
+               i = index_in_array(tas5086_charge_period,
+                                  ARRAY_SIZE(tas5086_charge_period),
+                                  priv->charge_period);
+               if (i >= 0)
+                       regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE,
+                                    i + 0x08);
+               else
+                       dev_warn(dev,
+                                "Invalid split-cap charge period of %d ns.\n",
+                                priv->charge_period);
+       }
+
+       /* enable factory trim */
+       ret = regmap_write(priv->regmap, TAS5086_OSC_TRIM, 0x00);
+       if (ret < 0)
+               return ret;
+
+       /* start all channels */
+       ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x20);
+       if (ret < 0)
+               return ret;
+
+       /* mute all channels for now */
+       ret = regmap_write(priv->regmap, TAS5086_SOFT_MUTE,
+                          TAS5086_SOFT_MUTE_ALL);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
 /* TAS5086 controls */
 static const DECLARE_TLV_DB_SCALE(tas5086_dac_tlv, -10350, 50, 1);
 
@@ -691,14 +763,39 @@ static struct snd_soc_dai_driver tas5086_dai = {
 };
 
 #ifdef CONFIG_PM
+static int tas5086_soc_suspend(struct snd_soc_codec *codec)
+{
+       struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec);
+       int ret;
+
+       /* Shut down all channels */
+       ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x60);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
 static int tas5086_soc_resume(struct snd_soc_codec *codec)
 {
        struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec);
+       int ret;
+
+       tas5086_reset(priv);
+       regcache_mark_dirty(priv->regmap);
+
+       ret = tas5086_init(codec->dev, priv);
+       if (ret < 0)
+               return ret;
+
+       ret = regcache_sync(priv->regmap);
+       if (ret < 0)
+               return ret;
 
-       /* Restore codec state */
-       return regcache_sync(priv->regmap);
+       return 0;
 }
 #else
+#define tas5086_soc_suspend    NULL
 #define tas5086_soc_resume     NULL
 #endif /* CONFIG_PM */
 
@@ -710,23 +807,19 @@ static const struct of_device_id tas5086_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, tas5086_dt_ids);
 #endif
 
-/* charge period values in microseconds */
-static const int tas5086_charge_period[] = {
-         13000,  16900,   23400,   31200,   41600,   54600,   72800,   96200,
-        130000, 156000,  234000,  312000,  416000,  546000,  728000,  962000,
-       1300000, 169000, 2340000, 3120000, 4160000, 5460000, 7280000, 9620000,
-};
-
 static int tas5086_probe(struct snd_soc_codec *codec)
 {
        struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec);
-       int charge_period = 1300000; /* hardware default is 1300 ms */
-       u8 pwm_start_mid_z = 0;
        int i, ret;
 
+       priv->pwm_start_mid_z = 0;
+       priv->charge_period = 1300000; /* hardware default is 1300 ms */
+
        if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) {
                struct device_node *of_node = codec->dev->of_node;
-               of_property_read_u32(of_node, "ti,charge-period", &charge_period);
+
+               of_property_read_u32(of_node, "ti,charge-period",
+                                    &priv->charge_period);
 
                for (i = 0; i < 6; i++) {
                        char name[25];
@@ -735,43 +828,11 @@ static int tas5086_probe(struct snd_soc_codec *codec)
                                 "ti,mid-z-channel-%d", i + 1);
 
                        if (of_get_property(of_node, name, NULL) != NULL)
-                               pwm_start_mid_z |= 1 << i;
+                               priv->pwm_start_mid_z |= 1 << i;
                }
        }
 
-       /*
-        * If any of the channels is configured to start in Mid-Z mode,
-        * configure 'part 1' of the PWM starts to use Mid-Z, and tell
-        * all configured mid-z channels to start start under 'part 1'.
-        */
-       if (pwm_start_mid_z)
-               regmap_write(priv->regmap, TAS5086_PWM_START,
-                            TAS5086_PWM_START_MIDZ_FOR_START_1 |
-                               pwm_start_mid_z);
-
-       /* lookup and set split-capacitor charge period */
-       if (charge_period == 0) {
-               regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, 0);
-       } else {
-               i = index_in_array(tas5086_charge_period,
-                                  ARRAY_SIZE(tas5086_charge_period),
-                                  charge_period);
-               if (i >= 0)
-                       regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE,
-                                    i + 0x08);
-               else
-                       dev_warn(codec->dev,
-                                "Invalid split-cap charge period of %d ns.\n",
-                                charge_period);
-       }
-
-       /* enable factory trim */
-       ret = regmap_write(priv->regmap, TAS5086_OSC_TRIM, 0x00);
-       if (ret < 0)
-               return ret;
-
-       /* start all channels */
-       ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x20);
+       ret = tas5086_init(codec->dev, priv);
        if (ret < 0)
                return ret;
 
@@ -780,12 +841,6 @@ static int tas5086_probe(struct snd_soc_codec *codec)
        if (ret < 0)
                return ret;
 
-       /* mute all channels for now */
-       ret = regmap_write(priv->regmap, TAS5086_SOFT_MUTE,
-                          TAS5086_SOFT_MUTE_ALL);
-       if (ret < 0)
-               return ret;
-
        return 0;
 }
 
@@ -803,6 +858,7 @@ static int tas5086_remove(struct snd_soc_codec *codec)
 static struct snd_soc_codec_driver soc_codec_dev_tas5086 = {
        .probe                  = tas5086_probe,
        .remove                 = tas5086_remove,
+       .suspend                = tas5086_soc_suspend,
        .resume                 = tas5086_soc_resume,
        .controls               = tas5086_controls,
        .num_controls           = ARRAY_SIZE(tas5086_controls),
@@ -862,17 +918,8 @@ static int tas5086_i2c_probe(struct i2c_client *i2c,
                if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset"))
                        gpio_nreset = -EINVAL;
 
-       if (gpio_is_valid(gpio_nreset)) {
-               /* Reset codec - minimum assertion time is 400ns */
-               gpio_direction_output(gpio_nreset, 0);
-               udelay(1);
-               gpio_set_value(gpio_nreset, 1);
-
-               /* Codec needs ~15ms to wake up */
-               msleep(15);
-       }
-
        priv->gpio_nreset = gpio_nreset;
+       tas5086_reset(priv);
 
        /* The TAS5086 always returns 0x03 in its TAS5086_DEV_ID register */
        ret = regmap_read(priv->regmap, TAS5086_DEV_ID, &i);
index 31762ebdd774d1947c115542eb4041144345b1b9..5d430cc56f51d42397c3190bf3bfb55b7f850dae 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
+#include <linux/regmap.h>
 #include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 /*
  * AIC23 register cache
  */
-static const u16 tlv320aic23_reg[] = {
-       0x0097, 0x0097, 0x00F9, 0x00F9, /* 0 */
-       0x001A, 0x0004, 0x0007, 0x0001, /* 4 */
-       0x0020, 0x0000, 0x0000, 0x0000, /* 8 */
-       0x0000, 0x0000, 0x0000, 0x0000, /* 12 */
+static const struct reg_default tlv320aic23_reg[] = {
+       {  0, 0x0097 },
+       {  1, 0x0097 },
+       {  2, 0x00F9 },
+       {  3, 0x00F9 },
+       {  4, 0x001A },
+       {  5, 0x0004 },
+       {  6, 0x0007 },
+       {  7, 0x0001 },
+       {  8, 0x0020 },
+       {  9, 0x0000 },
+};
+
+static const struct regmap_config tlv320aic23_regmap = {
+       .reg_bits = 7,
+       .val_bits = 9,
+
+       .max_register = TLV320AIC23_RESET,
+       .reg_defaults = tlv320aic23_reg,
+       .num_reg_defaults = ARRAY_SIZE(tlv320aic23_reg),
+       .cache_type = REGCACHE_RBTREE,
 };
 
 static const char *rec_src_text[] = { "Line", "Mic" };
@@ -171,7 +188,7 @@ static const struct snd_soc_dapm_route tlv320aic23_intercon[] = {
 
 /* AIC23 driver data */
 struct aic23 {
-       enum snd_soc_control_type control_type;
+       struct regmap *regmap;
        int mclk;
        int requested_adc;
        int requested_dac;
@@ -532,7 +549,9 @@ static int tlv320aic23_suspend(struct snd_soc_codec *codec)
 
 static int tlv320aic23_resume(struct snd_soc_codec *codec)
 {
-       snd_soc_cache_sync(codec);
+       struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec);
+       regcache_mark_dirty(aic23->regmap);
+       regcache_sync(aic23->regmap);
        tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
        return 0;
@@ -540,10 +559,9 @@ static int tlv320aic23_resume(struct snd_soc_codec *codec)
 
 static int tlv320aic23_probe(struct snd_soc_codec *codec)
 {
-       struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec);
        int ret;
 
-       ret = snd_soc_codec_set_cache_io(codec, 7, 9, aic23->control_type);
+       ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
        if (ret < 0) {
                dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
                return ret;
@@ -552,16 +570,6 @@ static int tlv320aic23_probe(struct snd_soc_codec *codec)
        /* Reset codec */
        snd_soc_write(codec, TLV320AIC23_RESET, 0);
 
-       /* Write the register default value to cache for reserved registers,
-        * so the write to the these registers are suppressed by the cache
-        * restore code when it skips writes of default registers.
-        */
-       snd_soc_cache_write(codec, 0x0A, 0);
-       snd_soc_cache_write(codec, 0x0B, 0);
-       snd_soc_cache_write(codec, 0x0C, 0);
-       snd_soc_cache_write(codec, 0x0D, 0);
-       snd_soc_cache_write(codec, 0x0E, 0);
-
        /* power on device */
        tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
@@ -586,9 +594,6 @@ static int tlv320aic23_probe(struct snd_soc_codec *codec)
 
        snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x1);
 
-       snd_soc_add_codec_controls(codec, tlv320aic23_snd_controls,
-                               ARRAY_SIZE(tlv320aic23_snd_controls));
-
        return 0;
 }
 
@@ -599,21 +604,19 @@ static int tlv320aic23_remove(struct snd_soc_codec *codec)
 }
 
 static struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = {
-       .reg_cache_size = ARRAY_SIZE(tlv320aic23_reg),
-       .reg_word_size = sizeof(u16),
-       .reg_cache_default = tlv320aic23_reg,
        .probe = tlv320aic23_probe,
        .remove = tlv320aic23_remove,
        .suspend = tlv320aic23_suspend,
        .resume = tlv320aic23_resume,
        .set_bias_level = tlv320aic23_set_bias_level,
+       .controls = tlv320aic23_snd_controls,
+       .num_controls = ARRAY_SIZE(tlv320aic23_snd_controls),
        .dapm_widgets = tlv320aic23_dapm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets),
        .dapm_routes = tlv320aic23_intercon,
        .num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon),
 };
 
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 /*
  * If the i2c layer weren't so broken, we could pass this kind of data
  * around
@@ -631,8 +634,11 @@ static int tlv320aic23_codec_probe(struct i2c_client *i2c,
        if (aic23 == NULL)
                return -ENOMEM;
 
+       aic23->regmap = devm_regmap_init_i2c(i2c, &tlv320aic23_regmap);
+       if (IS_ERR(aic23->regmap))
+               return PTR_ERR(aic23->regmap);
+
        i2c_set_clientdata(i2c, aic23);
-       aic23->control_type = SND_SOC_I2C;
 
        ret =  snd_soc_register_codec(&i2c->dev,
                        &soc_codec_dev_tlv320aic23, &tlv320aic23_dai, 1);
@@ -660,29 +666,7 @@ static struct i2c_driver tlv320aic23_i2c_driver = {
        .id_table = tlv320aic23_id,
 };
 
-#endif
-
-static int __init tlv320aic23_modinit(void)
-{
-       int ret;
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
-       ret = i2c_add_driver(&tlv320aic23_i2c_driver);
-       if (ret != 0) {
-               printk(KERN_ERR "Failed to register TLV320AIC23 I2C driver: %d\n",
-                      ret);
-       }
-#endif
-       return ret;
-}
-module_init(tlv320aic23_modinit);
-
-static void __exit tlv320aic23_exit(void)
-{
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
-       i2c_del_driver(&tlv320aic23_i2c_driver);
-#endif
-}
-module_exit(tlv320aic23_exit);
+module_i2c_driver(tlv320aic23_i2c_driver);
 
 MODULE_DESCRIPTION("ASoC TLV320AIC23 codec driver");
 MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
index 7b8f3d965f43c814b9b5f5f918ddc6c8778129d4..94a658fa6d97408e84682cea3e3ecc4c9a01cc1d 100644 (file)
@@ -29,6 +29,7 @@ MODULE_LICENSE("GPL");
 /* AIC26 driver private data */
 struct aic26 {
        struct spi_device *spi;
+       struct regmap *regmap;
        struct snd_soc_codec *codec;
        int master;
        int datfm;
@@ -40,85 +41,6 @@ struct aic26 {
        int keyclick_len;
 };
 
-/* ---------------------------------------------------------------------
- * Register access routines
- */
-static unsigned int aic26_reg_read(struct snd_soc_codec *codec,
-                                  unsigned int reg)
-{
-       struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec);
-       u16 *cache = codec->reg_cache;
-       u16 cmd, value;
-       u8 buffer[2];
-       int rc;
-
-       if (reg >= AIC26_NUM_REGS) {
-               WARN_ON_ONCE(1);
-               return 0;
-       }
-
-       /* Do SPI transfer; first 16bits are command; remaining is
-        * register contents */
-       cmd = AIC26_READ_COMMAND_WORD(reg);
-       buffer[0] = (cmd >> 8) & 0xff;
-       buffer[1] = cmd & 0xff;
-       rc = spi_write_then_read(aic26->spi, buffer, 2, buffer, 2);
-       if (rc) {
-               dev_err(&aic26->spi->dev, "AIC26 reg read error\n");
-               return -EIO;
-       }
-       value = (buffer[0] << 8) | buffer[1];
-
-       /* Update the cache before returning with the value */
-       cache[reg] = value;
-       return value;
-}
-
-static unsigned int aic26_reg_read_cache(struct snd_soc_codec *codec,
-                                        unsigned int reg)
-{
-       u16 *cache = codec->reg_cache;
-
-       if (reg >= AIC26_NUM_REGS) {
-               WARN_ON_ONCE(1);
-               return 0;
-       }
-
-       return cache[reg];
-}
-
-static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg,
-                          unsigned int value)
-{
-       struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec);
-       u16 *cache = codec->reg_cache;
-       u16 cmd;
-       u8 buffer[4];
-       int rc;
-
-       if (reg >= AIC26_NUM_REGS) {
-               WARN_ON_ONCE(1);
-               return -EINVAL;
-       }
-
-       /* Do SPI transfer; first 16bits are command; remaining is data
-        * to write into register */
-       cmd = AIC26_WRITE_COMMAND_WORD(reg);
-       buffer[0] = (cmd >> 8) & 0xff;
-       buffer[1] = cmd & 0xff;
-       buffer[2] = value >> 8;
-       buffer[3] = value;
-       rc = spi_write(aic26->spi, buffer, 4);
-       if (rc) {
-               dev_err(&aic26->spi->dev, "AIC26 reg read error\n");
-               return -EIO;
-       }
-
-       /* update cache before returning */
-       cache[reg] = value;
-       return 0;
-}
-
 static const struct snd_soc_dapm_widget tlv320aic26_dapm_widgets[] = {
 SND_SOC_DAPM_INPUT("MICIN"),
 SND_SOC_DAPM_INPUT("AUX"),
@@ -195,19 +117,15 @@ static int aic26_hw_params(struct snd_pcm_substream *substream,
        snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg);
 
        /* Audio Control 3 (master mode, fsref rate) */
-       reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL3);
-       reg &= ~0xf800;
        if (aic26->master)
-               reg |= 0x0800;
+               reg = 0x0800;
        if (fsref == 48000)
-               reg |= 0x2000;
-       snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg);
+               reg = 0x2000;
+       snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg);
 
        /* Audio Control 1 (FSref divisor) */
-       reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL1);
-       reg &= ~0x0fff;
-       reg |= wlen | aic26->datfm | (divisor << 3) | divisor;
-       snd_soc_write(codec, AIC26_REG_AUDIO_CTRL1, reg);
+       reg = wlen | aic26->datfm | (divisor << 3) | divisor;
+       snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg);
 
        return 0;
 }
@@ -219,16 +137,16 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute)
 {
        struct snd_soc_codec *codec = dai->codec;
        struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec);
-       u16 reg = aic26_reg_read_cache(codec, AIC26_REG_DAC_GAIN);
+       u16 reg;
 
        dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n",
                dai, mute);
 
        if (mute)
-               reg |= 0x8080;
+               reg = 0x8080;
        else
-               reg &= ~0x8080;
-       snd_soc_write(codec, AIC26_REG_DAC_GAIN, reg);
+               reg 0;
+       snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg);
 
        return 0;
 }
@@ -346,7 +264,7 @@ static ssize_t aic26_keyclick_show(struct device *dev,
        struct aic26 *aic26 = dev_get_drvdata(dev);
        int val, amp, freq, len;
 
-       val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2);
+       val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2);
        amp = (val >> 12) & 0x7;
        freq = (125 << ((val >> 8) & 0x7)) >> 1;
        len = 2 * (1 + ((val >> 4) & 0xf));
@@ -360,11 +278,9 @@ static ssize_t aic26_keyclick_set(struct device *dev,
                                  const char *buf, size_t count)
 {
        struct aic26 *aic26 = dev_get_drvdata(dev);
-       int val;
 
-       val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2);
-       val |= 0x8000;
-       snd_soc_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val);
+       snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2,
+                           0x8000, 0x800);
 
        return count;
 }
@@ -377,7 +293,9 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
 static int aic26_probe(struct snd_soc_codec *codec)
 {
        struct aic26 *aic26 = dev_get_drvdata(codec->dev);
-       int ret, err, i, reg;
+       int ret, reg;
+
+       snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
 
        aic26->codec = codec;
 
@@ -393,37 +311,30 @@ static int aic26_probe(struct snd_soc_codec *codec)
        reg |= 0x0800; /* set master mode */
        snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg);
 
-       /* Fill register cache */
-       for (i = 0; i < codec->driver->reg_cache_size; i++)
-               snd_soc_read(codec, i);
-
        /* Register the sysfs files for debugging */
        /* Create SysFS files */
        ret = device_create_file(codec->dev, &dev_attr_keyclick);
        if (ret)
                dev_info(codec->dev, "error creating sysfs files\n");
 
-       /* register controls */
-       dev_dbg(codec->dev, "Registering controls\n");
-       err = snd_soc_add_codec_controls(codec, aic26_snd_controls,
-                       ARRAY_SIZE(aic26_snd_controls));
-       WARN_ON(err < 0);
-
        return 0;
 }
 
 static struct snd_soc_codec_driver aic26_soc_codec_dev = {
        .probe = aic26_probe,
-       .read = aic26_reg_read,
-       .write = aic26_reg_write,
-       .reg_cache_size = AIC26_NUM_REGS,
-       .reg_word_size = sizeof(u16),
+       .controls = aic26_snd_controls,
+       .num_controls = ARRAY_SIZE(aic26_snd_controls),
        .dapm_widgets = tlv320aic26_dapm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets),
        .dapm_routes = tlv320aic26_dapm_routes,
        .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes),
 };
 
+static const struct regmap_config aic26_regmap = {
+       .reg_bits = 16,
+       .val_bits = 16,
+};
+
 /* ---------------------------------------------------------------------
  * SPI device portion of driver: probe and release routines and SPI
  *                              driver registration.
@@ -440,6 +351,10 @@ static int aic26_spi_probe(struct spi_device *spi)
        if (!aic26)
                return -ENOMEM;
 
+       aic26->regmap = devm_regmap_init_spi(spi, &aic26_regmap);
+       if (IS_ERR(aic26->regmap))
+               return PTR_ERR(aic26->regmap);
+
        /* Initialize the driver data */
        aic26->spi = spi;
        dev_set_drvdata(&spi->dev, aic26);
index 67f19c3bebe6a88a6d86a81f32b2f6dca25c65ec..629b85e75409383df910d448eabb97b2e8b5dc8e 100644 (file)
@@ -9,10 +9,7 @@
 #define _TLV320AIC16_H_
 
 /* AIC26 Registers */
-#define AIC26_READ_COMMAND_WORD(addr)  ((1 << 15) | (addr << 5))
-#define AIC26_WRITE_COMMAND_WORD(addr) ((0 << 15) | (addr << 5))
-#define AIC26_PAGE_ADDR(page, offset)  ((page << 6) | offset)
-#define AIC26_NUM_REGS                 AIC26_PAGE_ADDR(3, 0)
+#define AIC26_PAGE_ADDR(page, offset)  ((page << 11) | offset << 5)
 
 /* Page 0: Auxiliary data registers */
 #define AIC26_REG_BAT1                 AIC26_PAGE_ADDR(0, 0x05)
index 2ed57d4aa4456e4e614ca85765846d1d8aa78cf2..18cdcca9014cc66d394dd9e1df875f6edc2a7874 100644 (file)
@@ -60,9 +60,8 @@ struct aic32x4_rate_divs {
 };
 
 struct aic32x4_priv {
+       struct regmap *regmap;
        u32 sysclk;
-       u8 page_no;
-       void *control_data;
        u32 power_cfg;
        u32 micpga_routing;
        bool swapdacs;
@@ -262,67 +261,25 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
        {"Right ADC", NULL, "Right Input Mixer"},
 };
 
-static inline int aic32x4_change_page(struct snd_soc_codec *codec,
-                                       unsigned int new_page)
-{
-       struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
-       u8 data[2];
-       int ret;
-
-       data[0] = 0x00;
-       data[1] = new_page & 0xff;
-
-       ret = codec->hw_write(codec->control_data, data, 2);
-       if (ret == 2) {
-               aic32x4->page_no = new_page;
-               return 0;
-       } else {
-               return ret;
-       }
-}
-
-static int aic32x4_write(struct snd_soc_codec *codec, unsigned int reg,
-                               unsigned int val)
-{
-       struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
-       unsigned int page = reg / 128;
-       unsigned int fixed_reg = reg % 128;
-       u8 data[2];
-       int ret;
-
-       /* A write to AIC32X4_PSEL is really a non-explicit page change */
-       if (reg == AIC32X4_PSEL)
-               return aic32x4_change_page(codec, val);
-
-       if (aic32x4->page_no != page) {
-               ret = aic32x4_change_page(codec, page);
-               if (ret != 0)
-                       return ret;
-       }
-
-       data[0] = fixed_reg & 0xff;
-       data[1] = val & 0xff;
-
-       if (codec->hw_write(codec->control_data, data, 2) == 2)
-               return 0;
-       else
-               return -EIO;
-}
+static const struct regmap_range_cfg aic32x4_regmap_pages[] = {
+       {
+               .selector_reg = 0,
+               .selector_mask  = 0xff,
+               .window_start = 0,
+               .window_len = 128,
+               .range_min = AIC32X4_PAGE1,
+               .range_max = AIC32X4_PAGE1 + 127,
+       },
+};
 
-static unsigned int aic32x4_read(struct snd_soc_codec *codec, unsigned int reg)
-{
-       struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
-       unsigned int page = reg / 128;
-       unsigned int fixed_reg = reg % 128;
-       int ret;
+static const struct regmap_config aic32x4_regmap = {
+       .reg_bits = 8,
+       .val_bits = 8,
 
-       if (aic32x4->page_no != page) {
-               ret = aic32x4_change_page(codec, page);
-               if (ret != 0)
-                       return ret;
-       }
-       return i2c_smbus_read_byte_data(codec->control_data, fixed_reg & 0xff);
-}
+       .max_register = AIC32X4_RMICPGAVOL,
+       .ranges = aic32x4_regmap_pages,
+       .num_ranges = ARRAY_SIZE(aic32x4_regmap_pages),
+};
 
 static inline int aic32x4_get_divs(int mclk, int rate)
 {
@@ -617,16 +574,10 @@ static int aic32x4_probe(struct snd_soc_codec *codec)
 {
        struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
        u32 tmp_reg;
-       int ret;
 
-       codec->hw_write = (hw_write_t) i2c_master_send;
-       codec->control_data = aic32x4->control_data;
+       snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
 
        if (aic32x4->rstn_gpio >= 0) {
-               ret = devm_gpio_request_one(codec->dev, aic32x4->rstn_gpio,
-                               GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn");
-               if (ret != 0)
-                       return ret;
                ndelay(10);
                gpio_set_value(aic32x4->rstn_gpio, 1);
        }
@@ -692,8 +643,6 @@ static int aic32x4_remove(struct snd_soc_codec *codec)
 }
 
 static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = {
-       .read = aic32x4_read,
-       .write = aic32x4_write,
        .probe = aic32x4_probe,
        .remove = aic32x4_remove,
        .suspend = aic32x4_suspend,
@@ -720,7 +669,10 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c,
        if (aic32x4 == NULL)
                return -ENOMEM;
 
-       aic32x4->control_data = i2c;
+       aic32x4->regmap = devm_regmap_init_i2c(i2c, &aic32x4_regmap);
+       if (IS_ERR(aic32x4->regmap))
+               return PTR_ERR(aic32x4->regmap);
+
        i2c_set_clientdata(i2c, aic32x4);
 
        if (pdata) {
@@ -735,6 +687,13 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c,
                aic32x4->rstn_gpio = -1;
        }
 
+       if (aic32x4->rstn_gpio >= 0) {
+               ret = devm_gpio_request_one(&i2c->dev, aic32x4->rstn_gpio,
+                               GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn");
+               if (ret != 0)
+                       return ret;
+       }
+
        ret = snd_soc_register_codec(&i2c->dev,
                        &soc_codec_dev_aic32x4, &aic32x4_dai, 1);
        return ret;
index 64ad84d8a3061e5e4ba824c7178d10f87921c797..546d16b7d38f87cd456e35286dbf3b9a8eab4b33 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/i2c.h>
 #include <linux/gpio.h>
 #include <linux/regulator/consumer.h>
+#include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/slab.h>
 #include <sound/core.h>
@@ -72,9 +73,9 @@ struct aic3x_disable_nb {
 /* codec private data */
 struct aic3x_priv {
        struct snd_soc_codec *codec;
+       struct regmap *regmap;
        struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES];
        struct aic3x_disable_nb disable_nb[AIC3X_NUM_SUPPLIES];
-       enum snd_soc_control_type control_type;
        struct aic3x_setup_data *setup;
        unsigned int sysclk;
        struct list_head list;
@@ -90,41 +91,45 @@ struct aic3x_priv {
        enum aic3x_micbias_voltage micbias_vg;
 };
 
-/*
- * AIC3X register cache
- * We can't read the AIC3X register space when we are
- * using 2 wire for device control, so we cache them instead.
- * There is no point in caching the reset register
- */
-static const u8 aic3x_reg[AIC3X_CACHEREGNUM] = {
-       0x00, 0x00, 0x00, 0x10, /* 0 */
-       0x04, 0x00, 0x00, 0x00, /* 4 */
-       0x00, 0x00, 0x00, 0x01, /* 8 */
-       0x00, 0x00, 0x00, 0x80, /* 12 */
-       0x80, 0xff, 0xff, 0x78, /* 16 */
-       0x78, 0x78, 0x78, 0x78, /* 20 */
-       0x78, 0x00, 0x00, 0xfe, /* 24 */
-       0x00, 0x00, 0xfe, 0x00, /* 28 */
-       0x18, 0x18, 0x00, 0x00, /* 32 */
-       0x00, 0x00, 0x00, 0x00, /* 36 */
-       0x00, 0x00, 0x00, 0x80, /* 40 */
-       0x80, 0x00, 0x00, 0x00, /* 44 */
-       0x00, 0x00, 0x00, 0x04, /* 48 */
-       0x00, 0x00, 0x00, 0x00, /* 52 */
-       0x00, 0x00, 0x04, 0x00, /* 56 */
-       0x00, 0x00, 0x00, 0x00, /* 60 */
-       0x00, 0x04, 0x00, 0x00, /* 64 */
-       0x00, 0x00, 0x00, 0x00, /* 68 */
-       0x04, 0x00, 0x00, 0x00, /* 72 */
-       0x00, 0x00, 0x00, 0x00, /* 76 */
-       0x00, 0x00, 0x00, 0x00, /* 80 */
-       0x00, 0x00, 0x00, 0x00, /* 84 */
-       0x00, 0x00, 0x00, 0x00, /* 88 */
-       0x00, 0x00, 0x00, 0x00, /* 92 */
-       0x00, 0x00, 0x00, 0x00, /* 96 */
-       0x00, 0x00, 0x02, 0x00, /* 100 */
-       0x00, 0x00, 0x00, 0x00, /* 104 */
-       0x00, 0x00,             /* 108 */
+static const struct reg_default aic3x_reg[] = {
+       {   0, 0x00 }, {   1, 0x00 }, {   2, 0x00 }, {   3, 0x10 },
+       {   4, 0x04 }, {   5, 0x00 }, {   6, 0x00 }, {   7, 0x00 },
+       {   8, 0x00 }, {   9, 0x00 }, {  10, 0x00 }, {  11, 0x01 },
+       {  12, 0x00 }, {  13, 0x00 }, {  14, 0x00 }, {  15, 0x80 },
+       {  16, 0x80 }, {  17, 0xff }, {  18, 0xff }, {  19, 0x78 },
+       {  20, 0x78 }, {  21, 0x78 }, {  22, 0x78 }, {  23, 0x78 },
+       {  24, 0x78 }, {  25, 0x00 }, {  26, 0x00 }, {  27, 0xfe },
+       {  28, 0x00 }, {  29, 0x00 }, {  30, 0xfe }, {  31, 0x00 },
+       {  32, 0x18 }, {  33, 0x18 }, {  34, 0x00 }, {  35, 0x00 },
+       {  36, 0x00 }, {  37, 0x00 }, {  38, 0x00 }, {  39, 0x00 },
+       {  40, 0x00 }, {  41, 0x00 }, {  42, 0x00 }, {  43, 0x80 },
+       {  44, 0x80 }, {  45, 0x00 }, {  46, 0x00 }, {  47, 0x00 },
+       {  48, 0x00 }, {  49, 0x00 }, {  50, 0x00 }, {  51, 0x04 },
+       {  52, 0x00 }, {  53, 0x00 }, {  54, 0x00 }, {  55, 0x00 },
+       {  56, 0x00 }, {  57, 0x00 }, {  58, 0x04 }, {  59, 0x00 },
+       {  60, 0x00 }, {  61, 0x00 }, {  62, 0x00 }, {  63, 0x00 },
+       {  64, 0x00 }, {  65, 0x04 }, {  66, 0x00 }, {  67, 0x00 },
+       {  68, 0x00 }, {  69, 0x00 }, {  70, 0x00 }, {  71, 0x00 },
+       {  72, 0x04 }, {  73, 0x00 }, {  74, 0x00 }, {  75, 0x00 },
+       {  76, 0x00 }, {  77, 0x00 }, {  78, 0x00 }, {  79, 0x00 },
+       {  80, 0x00 }, {  81, 0x00 }, {  82, 0x00 }, {  83, 0x00 },
+       {  84, 0x00 }, {  85, 0x00 }, {  86, 0x00 }, {  87, 0x00 },
+       {  88, 0x00 }, {  89, 0x00 }, {  90, 0x00 }, {  91, 0x00 },
+       {  92, 0x00 }, {  93, 0x00 }, {  94, 0x00 }, {  95, 0x00 },
+       {  96, 0x00 }, {  97, 0x00 }, {  98, 0x00 }, {  99, 0x00 },
+       { 100, 0x00 }, { 101, 0x00 }, { 102, 0x02 }, { 103, 0x00 },
+       { 104, 0x00 }, { 105, 0x00 }, { 106, 0x00 }, { 107, 0x00 },
+       { 108, 0x00 }, { 109, 0x00 },
+};
+
+static const struct regmap_config aic3x_regmap = {
+       .reg_bits = 8,
+       .val_bits = 8,
+
+       .max_register = DAC_ICC_ADJ,
+       .reg_defaults = aic3x_reg,
+       .num_reg_defaults = ARRAY_SIZE(aic3x_reg),
+       .cache_type = REGCACHE_RBTREE,
 };
 
 #define SOC_DAPM_SINGLE_AIC3X(xname, reg, shift, mask, invert) \
@@ -828,12 +833,6 @@ static int aic3x_add_widgets(struct snd_soc_codec *codec)
        struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
        struct snd_soc_dapm_context *dapm = &codec->dapm;
 
-       snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets,
-                                 ARRAY_SIZE(aic3x_dapm_widgets));
-
-       /* set up audio path interconnects */
-       snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
-
        if (aic3x->model == AIC3X_MODEL_3007) {
                snd_soc_dapm_new_controls(dapm, aic3007_dapm_widgets,
                        ARRAY_SIZE(aic3007_dapm_widgets));
@@ -1082,29 +1081,6 @@ static int aic3x_set_dai_fmt(struct snd_soc_dai *codec_dai,
        return 0;
 }
 
-static int aic3x_init_3007(struct snd_soc_codec *codec)
-{
-       u8 tmp1, tmp2, *cache = codec->reg_cache;
-
-       /*
-        * There is no need to cache writes to undocumented page 0xD but
-        * respective page 0 register cache entries must be preserved
-        */
-       tmp1 = cache[0xD];
-       tmp2 = cache[0x8];
-       /* Class-D speaker driver init; datasheet p. 46 */
-       snd_soc_write(codec, AIC3X_PAGE_SELECT, 0x0D);
-       snd_soc_write(codec, 0xD, 0x0D);
-       snd_soc_write(codec, 0x8, 0x5C);
-       snd_soc_write(codec, 0x8, 0x5D);
-       snd_soc_write(codec, 0x8, 0x5C);
-       snd_soc_write(codec, AIC3X_PAGE_SELECT, 0x00);
-       cache[0xD] = tmp1;
-       cache[0x8] = tmp2;
-
-       return 0;
-}
-
 static int aic3x_regulator_event(struct notifier_block *nb,
                                 unsigned long event, void *data)
 {
@@ -1119,7 +1095,7 @@ static int aic3x_regulator_event(struct notifier_block *nb,
                 */
                if (gpio_is_valid(aic3x->gpio_reset))
                        gpio_set_value(aic3x->gpio_reset, 0);
-               aic3x->codec->cache_sync = 1;
+               regcache_mark_dirty(aic3x->regmap);
        }
 
        return 0;
@@ -1128,8 +1104,7 @@ static int aic3x_regulator_event(struct notifier_block *nb,
 static int aic3x_set_power(struct snd_soc_codec *codec, int power)
 {
        struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
-       int i, ret;
-       u8 *cache = codec->reg_cache;
+       int ret;
 
        if (power) {
                ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies),
@@ -1137,12 +1112,6 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power)
                if (ret)
                        goto out;
                aic3x->power = 1;
-               /*
-                * Reset release and cache sync is necessary only if some
-                * supply was off or if there were cached writes
-                */
-               if (!codec->cache_sync)
-                       goto out;
 
                if (gpio_is_valid(aic3x->gpio_reset)) {
                        udelay(1);
@@ -1150,12 +1119,8 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power)
                }
 
                /* Sync reg_cache with the hardware */
-               codec->cache_only = 0;
-               for (i = AIC3X_SAMPLE_RATE_SEL_REG; i < ARRAY_SIZE(aic3x_reg); i++)
-                       snd_soc_write(codec, i, cache[i]);
-               if (aic3x->model == AIC3X_MODEL_3007)
-                       aic3x_init_3007(codec);
-               codec->cache_sync = 0;
+               regcache_cache_only(aic3x->regmap, false);
+               regcache_sync(aic3x->regmap);
        } else {
                /*
                 * Do soft reset to this codec instance in order to clear
@@ -1163,10 +1128,10 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power)
                 * remain on
                 */
                snd_soc_write(codec, AIC3X_RESET, SOFT_RESET);
-               codec->cache_sync = 1;
+               regcache_mark_dirty(aic3x->regmap);
                aic3x->power = 0;
                /* HW writes are needless when bias is off */
-               codec->cache_only = 1;
+               regcache_cache_only(aic3x->regmap, true);
                ret = regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies),
                                             aic3x->supplies);
        }
@@ -1321,7 +1286,6 @@ static int aic3x_init(struct snd_soc_codec *codec)
        snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL);
 
        if (aic3x->model == AIC3X_MODEL_3007) {
-               aic3x_init_3007(codec);
                snd_soc_write(codec, CLASSD_CTRL, 0);
        }
 
@@ -1349,29 +1313,12 @@ static int aic3x_probe(struct snd_soc_codec *codec)
        INIT_LIST_HEAD(&aic3x->list);
        aic3x->codec = codec;
 
-       ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type);
+       ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
        if (ret != 0) {
                dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
                return ret;
        }
 
-       if (gpio_is_valid(aic3x->gpio_reset) &&
-           !aic3x_is_shared_reset(aic3x)) {
-               ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset");
-               if (ret != 0)
-                       goto err_gpio;
-               gpio_direction_output(aic3x->gpio_reset, 0);
-       }
-
-       for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
-               aic3x->supplies[i].supply = aic3x_supply_names[i];
-
-       ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(aic3x->supplies),
-                                aic3x->supplies);
-       if (ret != 0) {
-               dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
-               goto err_get;
-       }
        for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) {
                aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event;
                aic3x->disable_nb[i].aic3x = aic3x;
@@ -1385,7 +1332,7 @@ static int aic3x_probe(struct snd_soc_codec *codec)
                }
        }
 
-       codec->cache_only = 1;
+       regcache_mark_dirty(aic3x->regmap);
        aic3x_init(codec);
 
        if (aic3x->setup) {
@@ -1396,8 +1343,6 @@ static int aic3x_probe(struct snd_soc_codec *codec)
                              (aic3x->setup->gpio_func[1] & 0xf) << 4);
        }
 
-       snd_soc_add_codec_controls(codec, aic3x_snd_controls,
-                            ARRAY_SIZE(aic3x_snd_controls));
        if (aic3x->model == AIC3X_MODEL_3007)
                snd_soc_add_codec_controls(codec, &aic3x_classd_amp_gain_ctrl, 1);
 
@@ -1428,12 +1373,6 @@ err_notif:
        while (i--)
                regulator_unregister_notifier(aic3x->supplies[i].consumer,
                                              &aic3x->disable_nb[i].nb);
-       regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies);
-err_get:
-       if (gpio_is_valid(aic3x->gpio_reset) &&
-           !aic3x_is_shared_reset(aic3x))
-               gpio_free(aic3x->gpio_reset);
-err_gpio:
        return ret;
 }
 
@@ -1444,15 +1383,9 @@ static int aic3x_remove(struct snd_soc_codec *codec)
 
        aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF);
        list_del(&aic3x->list);
-       if (gpio_is_valid(aic3x->gpio_reset) &&
-           !aic3x_is_shared_reset(aic3x)) {
-               gpio_set_value(aic3x->gpio_reset, 0);
-               gpio_free(aic3x->gpio_reset);
-       }
        for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
                regulator_unregister_notifier(aic3x->supplies[i].consumer,
                                              &aic3x->disable_nb[i].nb);
-       regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies);
 
        return 0;
 }
@@ -1460,13 +1393,16 @@ static int aic3x_remove(struct snd_soc_codec *codec)
 static struct snd_soc_codec_driver soc_codec_dev_aic3x = {
        .set_bias_level = aic3x_set_bias_level,
        .idle_bias_off = true,
-       .reg_cache_size = ARRAY_SIZE(aic3x_reg),
-       .reg_word_size = sizeof(u8),
-       .reg_cache_default = aic3x_reg,
        .probe = aic3x_probe,
        .remove = aic3x_remove,
        .suspend = aic3x_suspend,
        .resume = aic3x_resume,
+       .controls = aic3x_snd_controls,
+       .num_controls = ARRAY_SIZE(aic3x_snd_controls),
+       .dapm_widgets = aic3x_dapm_widgets,
+       .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets),
+       .dapm_routes = intercon,
+       .num_dapm_routes = ARRAY_SIZE(intercon),
 };
 
 /*
@@ -1483,6 +1419,16 @@ static const struct i2c_device_id aic3x_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
 
+static const struct reg_default aic3007_class_d[] = {
+       /* Class-D speaker driver init; datasheet p. 46 */
+       { AIC3X_PAGE_SELECT, 0x0D },
+       { 0xD, 0x0D },
+       { 0x8, 0x5C },
+       { 0x8, 0x5D },
+       { 0x8, 0x5C },
+       { AIC3X_PAGE_SELECT, 0x00 },
+};
+
 /*
  * If the i2c layer weren't so broken, we could pass this kind of data
  * around
@@ -1494,7 +1440,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
        struct aic3x_priv *aic3x;
        struct aic3x_setup_data *ai3x_setup;
        struct device_node *np = i2c->dev.of_node;
-       int ret;
+       int ret, i;
        u32 value;
 
        aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL);
@@ -1503,7 +1449,13 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
                return -ENOMEM;
        }
 
-       aic3x->control_type = SND_SOC_I2C;
+       aic3x->regmap = devm_regmap_init_i2c(i2c, &aic3x_regmap);
+       if (IS_ERR(aic3x->regmap)) {
+               ret = PTR_ERR(aic3x->regmap);
+               return ret;
+       }
+
+       regcache_cache_only(aic3x->regmap, true);
 
        i2c_set_clientdata(i2c, aic3x);
        if (pdata) {
@@ -1555,14 +1507,54 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 
        aic3x->model = id->driver_data;
 
+       if (gpio_is_valid(aic3x->gpio_reset) &&
+           !aic3x_is_shared_reset(aic3x)) {
+               ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset");
+               if (ret != 0)
+                       goto err;
+               gpio_direction_output(aic3x->gpio_reset, 0);
+       }
+
+       for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
+               aic3x->supplies[i].supply = aic3x_supply_names[i];
+
+       ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(aic3x->supplies),
+                                     aic3x->supplies);
+       if (ret != 0) {
+               dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
+               goto err_gpio;
+       }
+
+       if (aic3x->model == AIC3X_MODEL_3007) {
+               ret = regmap_register_patch(aic3x->regmap, aic3007_class_d,
+                                           ARRAY_SIZE(aic3007_class_d));
+               if (ret != 0)
+                       dev_err(&i2c->dev, "Failed to init class D: %d\n",
+                               ret);
+       }
+
        ret = snd_soc_register_codec(&i2c->dev,
                        &soc_codec_dev_aic3x, &aic3x_dai, 1);
        return ret;
+
+err_gpio:
+       if (gpio_is_valid(aic3x->gpio_reset) &&
+           !aic3x_is_shared_reset(aic3x))
+               gpio_free(aic3x->gpio_reset);
+err:
+       return ret;
 }
 
 static int aic3x_i2c_remove(struct i2c_client *client)
 {
+       struct aic3x_priv *aic3x = i2c_get_clientdata(client);
+
        snd_soc_unregister_codec(&client->dev);
+       if (gpio_is_valid(aic3x->gpio_reset) &&
+           !aic3x_is_shared_reset(aic3x)) {
+               gpio_set_value(aic3x->gpio_reset, 0);
+               gpio_free(aic3x->gpio_reset);
+       }
        return 0;
 }
 
index c58bee8346cef2223e4b0cb5b15cbc76991ccca5..998555f2a8aab99d19b0e9eaf2d0186662fa0fb1 100644 (file)
@@ -30,6 +30,7 @@
 #include <sound/tpa6130a2-plat.h>
 #include <sound/soc.h>
 #include <sound/tlv.h>
+#include <linux/of_gpio.h>
 
 #include "tpa6130a2.h"
 
@@ -364,30 +365,33 @@ static int tpa6130a2_probe(struct i2c_client *client,
 {
        struct device *dev;
        struct tpa6130a2_data *data;
-       struct tpa6130a2_platform_data *pdata;
+       struct tpa6130a2_platform_data *pdata = client->dev.platform_data;
+       struct device_node *np = client->dev.of_node;
        const char *regulator;
        int ret;
 
        dev = &client->dev;
 
-       if (client->dev.platform_data == NULL) {
-               dev_err(dev, "Platform data not set\n");
-               dump_stack();
-               return -ENODEV;
-       }
-
        data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
        if (data == NULL) {
                dev_err(dev, "Can not allocate memory\n");
                return -ENOMEM;
        }
 
+       if (pdata) {
+               data->power_gpio = pdata->power_gpio;
+       } else if (np) {
+               data->power_gpio = of_get_named_gpio(np, "power-gpio", 0);
+       } else {
+               dev_err(dev, "Platform data not set\n");
+               dump_stack();
+               return -ENODEV;
+       }
+
        tpa6130a2_client = client;
 
        i2c_set_clientdata(tpa6130a2_client, data);
 
-       pdata = client->dev.platform_data;
-       data->power_gpio = pdata->power_gpio;
        data->id = id->driver_data;
 
        mutex_init(&data->mutex);
@@ -466,10 +470,20 @@ static const struct i2c_device_id tpa6130a2_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, tpa6130a2_id);
 
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id tpa6130a2_of_match[] = {
+       { .compatible = "ti,tpa6130a2", },
+       { .compatible = "ti,tpa6140a2" },
+       {},
+};
+MODULE_DEVICE_TABLE(of, tpa6130a2_of_match);
+#endif
+
 static struct i2c_driver tpa6130a2_i2c_driver = {
        .driver = {
                .name = "tpa6130a2",
                .owner = THIS_MODULE,
+               .of_match_table = of_match_ptr(tpa6130a2_of_match),
        },
        .probe = tpa6130a2_probe,
        .remove = tpa6130a2_remove,
index 1e3884d6b3fbc7202cedb6fe478e5d00e71da49b..dfc51bb425da93b5dc6e2ac55af8ea3125b9e1b9 100644 (file)
 /* TWL4030 PMBR1 Register GPIO6 mux bits */
 #define TWL4030_GPIO6_PWM0_MUTE(value) ((value & 0x03) << 2)
 
-/* Shadow register used by the audio driver */
-#define TWL4030_REG_SW_SHADOW          0x4A
-#define TWL4030_CACHEREGNUM    (TWL4030_REG_SW_SHADOW + 1)
-
-/* TWL4030_REG_SW_SHADOW (0x4A) Fields */
-#define TWL4030_HFL_EN                 0x01
-#define TWL4030_HFR_EN                 0x02
+#define TWL4030_CACHEREGNUM    (TWL4030_REG_MISC_SET_2 + 1)
 
 /*
  * twl4030 register cache & default register settings
@@ -132,7 +126,6 @@ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = {
        0x00, /* REG_VIBRA_PWM_SET      (0x47)  */
        0x00, /* REG_ANAMIC_GAIN        (0x48)  */
        0x00, /* REG_MISC_SET_2         (0x49)  */
-       0x00, /* REG_SW_SHADOW          (0x4A)  - Shadow, non HW register */
 };
 
 /* codec private data */
@@ -198,42 +191,41 @@ static int twl4030_write(struct snd_soc_codec *codec,
        int write_to_reg = 0;
 
        twl4030_write_reg_cache(codec, reg, value);
-       if (likely(reg < TWL4030_REG_SW_SHADOW)) {
-               /* Decide if the given register can be written */
-               switch (reg) {
-               case TWL4030_REG_EAR_CTL:
-                       if (twl4030->earpiece_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_PREDL_CTL:
-                       if (twl4030->predrivel_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_PREDR_CTL:
-                       if (twl4030->predriver_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_PRECKL_CTL:
-                       if (twl4030->carkitl_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_PRECKR_CTL:
-                       if (twl4030->carkitr_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_HS_GAIN_SET:
-                       if (twl4030->hsl_enabled || twl4030->hsr_enabled)
-                               write_to_reg = 1;
-                       break;
-               default:
-                       /* All other register can be written */
+       /* Decide if the given register can be written */
+       switch (reg) {
+       case TWL4030_REG_EAR_CTL:
+               if (twl4030->earpiece_enabled)
                        write_to_reg = 1;
-                       break;
-               }
-               if (write_to_reg)
-                       return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
-                                                   value, reg);
+               break;
+       case TWL4030_REG_PREDL_CTL:
+               if (twl4030->predrivel_enabled)
+                       write_to_reg = 1;
+               break;
+       case TWL4030_REG_PREDR_CTL:
+               if (twl4030->predriver_enabled)
+                       write_to_reg = 1;
+               break;
+       case TWL4030_REG_PRECKL_CTL:
+               if (twl4030->carkitl_enabled)
+                       write_to_reg = 1;
+               break;
+       case TWL4030_REG_PRECKR_CTL:
+               if (twl4030->carkitr_enabled)
+                       write_to_reg = 1;
+               break;
+       case TWL4030_REG_HS_GAIN_SET:
+               if (twl4030->hsl_enabled || twl4030->hsr_enabled)
+                       write_to_reg = 1;
+               break;
+       default:
+               /* All other register can be written */
+               write_to_reg = 1;
+               break;
        }
+       if (write_to_reg)
+               return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
+                                           value, reg);
+
        return 0;
 }
 
@@ -532,7 +524,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum);
 
 /* Handsfree Left virtual mute */
 static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control =
-       SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 0, 1, 0);
+       SOC_DAPM_SINGLE_VIRT("Switch", 1);
 
 /* Handsfree Right */
 static const char *twl4030_handsfreer_texts[] =
@@ -548,7 +540,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
 
 /* Handsfree Right virtual mute */
 static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control =
-       SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 1, 1, 0);
+       SOC_DAPM_SINGLE_VIRT("Switch", 1);
 
 /* Vibra */
 /* Vibra audio path selection */
index 3c79dbb6c32323b36bc974616c5ff1157498f281..f2f4bcb2ff71527b6dde8b264be2c99de7bf4c37 100644 (file)
@@ -54,12 +54,7 @@ enum twl6040_dai_id {
 #define TWL6040_OUTHF_0dB 0x03
 #define TWL6040_OUTHF_M52dB 0x1D
 
-/* Shadow register used by the driver */
-#define TWL6040_REG_SW_SHADOW  0x2F
-#define TWL6040_CACHEREGNUM    (TWL6040_REG_SW_SHADOW + 1)
-
-/* TWL6040_REG_SW_SHADOW (0x2F) fields */
-#define TWL6040_EAR_PATH_ENABLE        0x01
+#define TWL6040_CACHEREGNUM    (TWL6040_REG_STATUS + 1)
 
 struct twl6040_jack_data {
        struct snd_soc_jack *jack;
@@ -135,8 +130,6 @@ static const u8 twl6040_reg[TWL6040_CACHEREGNUM] = {
        0x00, /* REG_HFOTRIM    0x2C    */
        0x09, /* REG_ACCCTL     0x2D    */
        0x00, /* REG_STATUS     0x2E (ro) */
-
-       0x00, /* REG_SW_SHADOW  0x2F - Shadow, non HW register */
 };
 
 /* List of registers to be restored after power up */
@@ -220,12 +213,8 @@ static int twl6040_read_reg_volatile(struct snd_soc_codec *codec,
        if (reg >= TWL6040_CACHEREGNUM)
                return -EIO;
 
-       if (likely(reg < TWL6040_REG_SW_SHADOW)) {
-               value = twl6040_reg_read(twl6040, reg);
-               twl6040_write_reg_cache(codec, reg, value);
-       } else {
-               value = twl6040_read_reg_cache(codec, reg);
-       }
+       value = twl6040_reg_read(twl6040, reg);
+       twl6040_write_reg_cache(codec, reg, value);
 
        return value;
 }
@@ -246,7 +235,7 @@ static bool twl6040_is_path_unmuted(struct snd_soc_codec *codec,
                return priv->dl2_unmuted;
        default:
                return 1;
-       };
+       }
 }
 
 /*
@@ -261,8 +250,7 @@ static int twl6040_write(struct snd_soc_codec *codec,
                return -EIO;
 
        twl6040_write_reg_cache(codec, reg, value);
-       if (likely(reg < TWL6040_REG_SW_SHADOW) &&
-           twl6040_is_path_unmuted(codec, reg))
+       if (twl6040_is_path_unmuted(codec, reg))
                return twl6040_reg_write(twl6040, reg, value);
        else
                return 0;
@@ -555,7 +543,7 @@ static const struct snd_kcontrol_new hfr_mux_controls =
        SOC_DAPM_ENUM("Route", twl6040_hf_enum[1]);
 
 static const struct snd_kcontrol_new ep_path_enable_control =
-       SOC_DAPM_SINGLE("Switch", TWL6040_REG_SW_SHADOW, 0, 1, 0);
+       SOC_DAPM_SINGLE_VIRT("Switch", 1);
 
 static const struct snd_kcontrol_new auxl_switch_control =
        SOC_DAPM_SINGLE("Switch", TWL6040_REG_HFLCTL, 6, 1, 0);
@@ -1100,7 +1088,7 @@ static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id i
                break;
        default:
                break;
-       };
+       }
 }
 
 static int twl6040_digital_mute(struct snd_soc_dai *dai, int mute)
index d2a092850283f36ed035f20e4e6cd0c51a20412b..48dc7d2fee36fc07c236f6e9a09ea74cdb38d824 100644 (file)
 
 #include "wm8400.h"
 
-/* Fake register for internal state */
-#define WM8400_INTDRIVBITS      (WM8400_REGISTER_COUNT + 1)
-#define WM8400_INMIXL_PWR                      0
-#define WM8400_AINLMUX_PWR                     1
-#define WM8400_INMIXR_PWR                      2
-#define WM8400_AINRMUX_PWR                     3
-
 static struct regulator_bulk_data power[] = {
        {
                .supply = "I2S1VDD",
@@ -74,32 +67,6 @@ struct wm8400_priv {
        int fll_in, fll_out;
 };
 
-static inline unsigned int wm8400_read(struct snd_soc_codec *codec,
-                                      unsigned int reg)
-{
-       struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec);
-
-       if (reg == WM8400_INTDRIVBITS)
-               return wm8400->fake_register;
-       else
-               return wm8400_reg_read(wm8400->wm8400, reg);
-}
-
-/*
- * write to the wm8400 register space
- */
-static int wm8400_write(struct snd_soc_codec *codec, unsigned int reg,
-       unsigned int value)
-{
-       struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec);
-
-       if (reg == WM8400_INTDRIVBITS) {
-               wm8400->fake_register = value;
-               return 0;
-       } else
-               return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value);
-}
-
 static void wm8400_codec_reset(struct snd_soc_codec *codec)
 {
        struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec);
@@ -352,32 +319,6 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME,
  * _DAPM_ Controls
  */
 
-static int inmixer_event (struct snd_soc_dapm_widget *w,
-       struct snd_kcontrol *kcontrol, int event)
-{
-       u16 reg, fakepower;
-
-       reg = snd_soc_read(w->codec, WM8400_POWER_MANAGEMENT_2);
-       fakepower = snd_soc_read(w->codec, WM8400_INTDRIVBITS);
-
-       if (fakepower & ((1 << WM8400_INMIXL_PWR) |
-               (1 << WM8400_AINLMUX_PWR))) {
-               reg |= WM8400_AINL_ENA;
-       } else {
-               reg &= ~WM8400_AINL_ENA;
-       }
-
-       if (fakepower & ((1 << WM8400_INMIXR_PWR) |
-               (1 << WM8400_AINRMUX_PWR))) {
-               reg |= WM8400_AINR_ENA;
-       } else {
-               reg &= ~WM8400_AINR_ENA;
-       }
-       snd_soc_write(w->codec, WM8400_POWER_MANAGEMENT_2, reg);
-
-       return 0;
-}
-
 static int outmixer_event (struct snd_soc_dapm_widget *w,
        struct snd_kcontrol * kcontrol, int event)
 {
@@ -658,27 +599,26 @@ SND_SOC_DAPM_MIXER("RIN34 PGA", WM8400_POWER_MANAGEMENT_2,
                   0, &wm8400_dapm_rin34_pga_controls[0],
                   ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)),
 
+SND_SOC_DAPM_SUPPLY("INL", WM8400_POWER_MANAGEMENT_2, WM8400_AINL_ENA_SHIFT,
+                   0, NULL, 0),
+SND_SOC_DAPM_SUPPLY("INR", WM8400_POWER_MANAGEMENT_2, WM8400_AINR_ENA_SHIFT,
+                   0, NULL, 0),
+
 /* INMIXL */
-SND_SOC_DAPM_MIXER_E("INMIXL", WM8400_INTDRIVBITS, WM8400_INMIXL_PWR, 0,
+SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0,
        &wm8400_dapm_inmixl_controls[0],
-       ARRAY_SIZE(wm8400_dapm_inmixl_controls),
-       inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
+       ARRAY_SIZE(wm8400_dapm_inmixl_controls)),
 
 /* AINLMUX */
-SND_SOC_DAPM_MUX_E("AILNMUX", WM8400_INTDRIVBITS, WM8400_AINLMUX_PWR, 0,
-       &wm8400_dapm_ainlmux_controls, inmixer_event,
-       SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
+SND_SOC_DAPM_MUX("AILNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainlmux_controls),
 
 /* INMIXR */
-SND_SOC_DAPM_MIXER_E("INMIXR", WM8400_INTDRIVBITS, WM8400_INMIXR_PWR, 0,
+SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0,
        &wm8400_dapm_inmixr_controls[0],
-       ARRAY_SIZE(wm8400_dapm_inmixr_controls),
-       inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
+       ARRAY_SIZE(wm8400_dapm_inmixr_controls)),
 
 /* AINRMUX */
-SND_SOC_DAPM_MUX_E("AIRNMUX", WM8400_INTDRIVBITS, WM8400_AINRMUX_PWR, 0,
-       &wm8400_dapm_ainrmux_controls, inmixer_event,
-       SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
+SND_SOC_DAPM_MUX("AIRNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainrmux_controls),
 
 /* Output Side */
 /* DACs */
@@ -789,11 +729,13 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = {
        {"LIN34 PGA", "LIN3 Switch", "LIN3"},
        {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"},
        /* INMIXL */
+       {"INMIXL", NULL, "INL"},
        {"INMIXL", "Record Left Volume", "LOMIX"},
        {"INMIXL", "LIN2 Volume", "LIN2"},
        {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"},
        {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"},
        /* AILNMUX */
+       {"AILNMUX", NULL, "INL"},
        {"AILNMUX", "INMIXL Mix", "INMIXL"},
        {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"},
        {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"},
@@ -808,12 +750,14 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = {
        /* RIN34 PGA */
        {"RIN34 PGA", "RIN3 Switch", "RIN3"},
        {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"},
-       /* INMIXL */
+       /* INMIXR */
+       {"INMIXR", NULL, "INR"},
        {"INMIXR", "Record Right Volume", "ROMIX"},
        {"INMIXR", "RIN2 Volume", "RIN2"},
        {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"},
        {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"},
        /* AIRNMUX */
+       {"AIRNMUX", NULL, "INR"},
        {"AIRNMUX", "INMIXR Mix", "INMIXR"},
        {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"},
        {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"},
@@ -1365,9 +1309,12 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec)
                return -ENOMEM;
 
        snd_soc_codec_set_drvdata(codec, priv);
-       codec->control_data = priv->wm8400 = wm8400;
+       priv->wm8400 = wm8400;
+       codec->control_data = wm8400->regmap;
        priv->codec = codec;
 
+       snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
+
        ret = devm_regulator_bulk_get(wm8400->dev,
                                 ARRAY_SIZE(power), &power[0]);
        if (ret != 0) {
@@ -1414,8 +1361,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8400 = {
        .remove =       wm8400_codec_remove,
        .suspend =      wm8400_suspend,
        .resume =       wm8400_resume,
-       .read = snd_soc_read,
-       .write = wm8400_write,
        .set_bias_level = wm8400_set_bias_level,
 
        .controls = wm8400_snd_controls,
index 11d80f3b61372d357870b44432d5e1f1c9f6e25c..2bf9ee7c54078d26854540fc2502ab387f42748c 100644 (file)
@@ -3242,7 +3242,7 @@ static void wm8962_free_beep(struct snd_soc_codec *codec)
 }
 #endif
 
-static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio)
+static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio)
 {
        int mask = 0;
        int val = 0;
@@ -3263,8 +3263,8 @@ static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio)
        }
 
        if (mask)
-               snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1,
-                                   mask, val);
+               regmap_update_bits(wm8962->regmap, WM8962_ANALOGUE_CLOCKING1,
+                                  mask, val);
 }
 
 #ifdef CONFIG_GPIOLIB
@@ -3276,7 +3276,6 @@ static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip)
 static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
 {
        struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
-       struct snd_soc_codec *codec = wm8962->codec;
 
        /* The WM8962 GPIOs aren't linearly numbered.  For simplicity
         * we export linear numbers and error out if the unsupported
@@ -3292,7 +3291,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
                return -EINVAL;
        }
 
-       wm8962_set_gpio_mode(codec, offset + 1);
+       wm8962_set_gpio_mode(wm8962, offset + 1);
 
        return 0;
 }
@@ -3376,8 +3375,7 @@ static int wm8962_probe(struct snd_soc_codec *codec)
 {
        int ret;
        struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
-       struct wm8962_pdata *pdata = &wm8962->pdata;
-       int i, trigger, irq_pol;
+       int i;
        bool dmicclk, dmicdat;
 
        wm8962->codec = codec;
@@ -3409,75 +3407,6 @@ static int wm8962_probe(struct snd_soc_codec *codec)
                }
        }
 
-       /* SYSCLK defaults to on; make sure it is off so we can safely
-        * write to registers if the device is declocked.
-        */
-       snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_ENA, 0);
-
-       /* Ensure we have soft control over all registers */
-       snd_soc_update_bits(codec, WM8962_CLOCKING2,
-                           WM8962_CLKREG_OVD, WM8962_CLKREG_OVD);
-
-       /* Ensure that the oscillator and PLLs are disabled */
-       snd_soc_update_bits(codec, WM8962_PLL2,
-                           WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA,
-                           0);
-
-       /* Apply static configuration for GPIOs */
-       for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++)
-               if (pdata->gpio_init[i]) {
-                       wm8962_set_gpio_mode(codec, i + 1);
-                       snd_soc_write(codec, 0x200 + i,
-                                       pdata->gpio_init[i] & 0xffff);
-               }
-
-
-       /* Put the speakers into mono mode? */
-       if (pdata->spk_mono)
-               snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_2,
-                               WM8962_SPK_MONO_MASK, WM8962_SPK_MONO);
-
-       /* Micbias setup, detection enable and detection
-        * threasholds. */
-       if (pdata->mic_cfg)
-               snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4,
-                                   WM8962_MICDET_ENA |
-                                   WM8962_MICDET_THR_MASK |
-                                   WM8962_MICSHORT_THR_MASK |
-                                   WM8962_MICBIAS_LVL,
-                                   pdata->mic_cfg);
-
-       /* Latch volume update bits */
-       snd_soc_update_bits(codec, WM8962_LEFT_INPUT_VOLUME,
-                           WM8962_IN_VU, WM8962_IN_VU);
-       snd_soc_update_bits(codec, WM8962_RIGHT_INPUT_VOLUME,
-                           WM8962_IN_VU, WM8962_IN_VU);
-       snd_soc_update_bits(codec, WM8962_LEFT_ADC_VOLUME,
-                           WM8962_ADC_VU, WM8962_ADC_VU);
-       snd_soc_update_bits(codec, WM8962_RIGHT_ADC_VOLUME,
-                           WM8962_ADC_VU, WM8962_ADC_VU);
-       snd_soc_update_bits(codec, WM8962_LEFT_DAC_VOLUME,
-                           WM8962_DAC_VU, WM8962_DAC_VU);
-       snd_soc_update_bits(codec, WM8962_RIGHT_DAC_VOLUME,
-                           WM8962_DAC_VU, WM8962_DAC_VU);
-       snd_soc_update_bits(codec, WM8962_SPKOUTL_VOLUME,
-                           WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
-       snd_soc_update_bits(codec, WM8962_SPKOUTR_VOLUME,
-                           WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
-       snd_soc_update_bits(codec, WM8962_HPOUTL_VOLUME,
-                           WM8962_HPOUT_VU, WM8962_HPOUT_VU);
-       snd_soc_update_bits(codec, WM8962_HPOUTR_VOLUME,
-                           WM8962_HPOUT_VU, WM8962_HPOUT_VU);
-
-       /* Stereo control for EQ */
-       snd_soc_update_bits(codec, WM8962_EQ1, WM8962_EQ_SHARED_COEFF, 0);
-
-       /* Don't debouce interrupts so we don't need SYSCLK */
-       snd_soc_update_bits(codec, WM8962_IRQ_DEBOUNCE,
-                           WM8962_FLL_LOCK_DB | WM8962_PLL3_LOCK_DB |
-                           WM8962_PLL2_LOCK_DB | WM8962_TEMP_SHUT_DB,
-                           0);
-
        wm8962_add_widgets(codec);
 
        /* Save boards having to disable DMIC when not in use */
@@ -3506,36 +3435,6 @@ static int wm8962_probe(struct snd_soc_codec *codec)
        wm8962_init_beep(codec);
        wm8962_init_gpio(codec);
 
-       if (wm8962->irq) {
-               if (pdata->irq_active_low) {
-                       trigger = IRQF_TRIGGER_LOW;
-                       irq_pol = WM8962_IRQ_POL;
-               } else {
-                       trigger = IRQF_TRIGGER_HIGH;
-                       irq_pol = 0;
-               }
-
-               snd_soc_update_bits(codec, WM8962_INTERRUPT_CONTROL,
-                                   WM8962_IRQ_POL, irq_pol);
-
-               ret = request_threaded_irq(wm8962->irq, NULL, wm8962_irq,
-                                          trigger | IRQF_ONESHOT,
-                                          "wm8962", codec->dev);
-               if (ret != 0) {
-                       dev_err(codec->dev, "Failed to request IRQ %d: %d\n",
-                               wm8962->irq, ret);
-                       wm8962->irq = 0;
-                       /* Non-fatal */
-               } else {
-                       /* Enable some IRQs by default */
-                       snd_soc_update_bits(codec,
-                                           WM8962_INTERRUPT_STATUS_2_MASK,
-                                           WM8962_FLL_LOCK_EINT |
-                                           WM8962_TEMP_SHUT_EINT |
-                                           WM8962_FIFOS_ERR_EINT, 0);
-               }
-       }
-
        return 0;
 }
 
@@ -3544,9 +3443,6 @@ static int wm8962_remove(struct snd_soc_codec *codec)
        struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
        int i;
 
-       if (wm8962->irq)
-               free_irq(wm8962->irq, codec);
-
        cancel_delayed_work_sync(&wm8962->mic_work);
 
        wm8962_free_gpio(codec);
@@ -3619,7 +3515,7 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
        struct wm8962_pdata *pdata = dev_get_platdata(&i2c->dev);
        struct wm8962_priv *wm8962;
        unsigned int reg;
-       int ret, i;
+       int ret, i, irq_pol, trigger;
 
        wm8962 = devm_kzalloc(&i2c->dev, sizeof(struct wm8962_priv),
                              GFP_KERNEL);
@@ -3704,6 +3600,77 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
                goto err_enable;
        }
 
+       /* SYSCLK defaults to on; make sure it is off so we can safely
+        * write to registers if the device is declocked.
+        */
+       regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2,
+                          WM8962_SYSCLK_ENA, 0);
+
+       /* Ensure we have soft control over all registers */
+       regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2,
+                          WM8962_CLKREG_OVD, WM8962_CLKREG_OVD);
+
+       /* Ensure that the oscillator and PLLs are disabled */
+       regmap_update_bits(wm8962->regmap, WM8962_PLL2,
+                          WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA,
+                          0);
+
+       /* Apply static configuration for GPIOs */
+       for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++)
+               if (pdata->gpio_init[i]) {
+                       wm8962_set_gpio_mode(wm8962, i + 1);
+                       regmap_write(wm8962->regmap, 0x200 + i,
+                                    pdata->gpio_init[i] & 0xffff);
+               }
+
+
+       /* Put the speakers into mono mode? */
+       if (pdata->spk_mono)
+               regmap_update_bits(wm8962->regmap, WM8962_CLASS_D_CONTROL_2,
+                                  WM8962_SPK_MONO_MASK, WM8962_SPK_MONO);
+
+       /* Micbias setup, detection enable and detection
+        * threasholds. */
+       if (pdata->mic_cfg)
+               regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4,
+                                  WM8962_MICDET_ENA |
+                                  WM8962_MICDET_THR_MASK |
+                                  WM8962_MICSHORT_THR_MASK |
+                                  WM8962_MICBIAS_LVL,
+                                  pdata->mic_cfg);
+
+       /* Latch volume update bits */
+       regmap_update_bits(wm8962->regmap, WM8962_LEFT_INPUT_VOLUME,
+                          WM8962_IN_VU, WM8962_IN_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME,
+                          WM8962_IN_VU, WM8962_IN_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_LEFT_ADC_VOLUME,
+                          WM8962_ADC_VU, WM8962_ADC_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_RIGHT_ADC_VOLUME,
+                          WM8962_ADC_VU, WM8962_ADC_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_LEFT_DAC_VOLUME,
+                          WM8962_DAC_VU, WM8962_DAC_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_RIGHT_DAC_VOLUME,
+                          WM8962_DAC_VU, WM8962_DAC_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_SPKOUTL_VOLUME,
+                          WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_SPKOUTR_VOLUME,
+                          WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_HPOUTL_VOLUME,
+                          WM8962_HPOUT_VU, WM8962_HPOUT_VU);
+       regmap_update_bits(wm8962->regmap, WM8962_HPOUTR_VOLUME,
+                          WM8962_HPOUT_VU, WM8962_HPOUT_VU);
+
+       /* Stereo control for EQ */
+       regmap_update_bits(wm8962->regmap, WM8962_EQ1,
+                          WM8962_EQ_SHARED_COEFF, 0);
+
+       /* Don't debouce interrupts so we don't need SYSCLK */
+       regmap_update_bits(wm8962->regmap, WM8962_IRQ_DEBOUNCE,
+                          WM8962_FLL_LOCK_DB | WM8962_PLL3_LOCK_DB |
+                          WM8962_PLL2_LOCK_DB | WM8962_TEMP_SHUT_DB,
+                          0);
+
        if (wm8962->pdata.in4_dc_measure) {
                ret = regmap_register_patch(wm8962->regmap,
                                            wm8962_dc_measure,
@@ -3714,6 +3681,37 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
                                ret);
        }
 
+       if (wm8962->irq) {
+               if (pdata->irq_active_low) {
+                       trigger = IRQF_TRIGGER_LOW;
+                       irq_pol = WM8962_IRQ_POL;
+               } else {
+                       trigger = IRQF_TRIGGER_HIGH;
+                       irq_pol = 0;
+               }
+
+               regmap_update_bits(wm8962->regmap, WM8962_INTERRUPT_CONTROL,
+                                  WM8962_IRQ_POL, irq_pol);
+
+               ret = devm_request_threaded_irq(&i2c->dev, wm8962->irq, NULL,
+                                               wm8962_irq,
+                                               trigger | IRQF_ONESHOT,
+                                               "wm8962", &i2c->dev);
+               if (ret != 0) {
+                       dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
+                               wm8962->irq, ret);
+                       wm8962->irq = 0;
+                       /* Non-fatal */
+               } else {
+                       /* Enable some IRQs by default */
+                       regmap_update_bits(wm8962->regmap,
+                                          WM8962_INTERRUPT_STATUS_2_MASK,
+                                          WM8962_FLL_LOCK_EINT |
+                                          WM8962_TEMP_SHUT_EINT |
+                                          WM8962_FIFOS_ERR_EINT, 0);
+               }
+       }
+
        pm_runtime_enable(&i2c->dev);
        pm_request_idle(&i2c->dev);
 
index c82f89c9475b2f7301ecd1d753c65d85431f3cc6..95970f5db3eca228df66a55f5e357f14b26209c9 100644 (file)
@@ -1,9 +1,10 @@
 config SND_DAVINCI_SOC
-       tristate "SoC Audio for the TI DAVINCI chip"
-       depends on ARCH_DAVINCI
+       tristate "SoC Audio for the TI DAVINCI or AM33XX chip"
+       depends on ARCH_DAVINCI || SOC_AM33XX
        help
+         Platform driver for daVinci or AM33xx
          Say Y or M if you want to add support for codecs attached to
-         the DAVINCI AC97 or I2S interface. You will also need
+         the DAVINCI AC97, I2S, or McASP interface. You will also need
          to select the audio interfaces to support below.
 
 config SND_DAVINCI_SOC_I2S
@@ -15,6 +16,17 @@ config SND_DAVINCI_SOC_MCASP
 config SND_DAVINCI_SOC_VCIF
        tristate
 
+config SND_AM33XX_SOC_EVM
+       tristate "SoC Audio for the AM33XX chip based boards"
+       depends on SND_DAVINCI_SOC && SOC_AM33XX
+       select SND_SOC_TLV320AIC3X
+       select SND_DAVINCI_SOC_MCASP
+       help
+         Say Y or M if you want to add support for SoC audio on AM33XX
+         boards using McASP and TLV320AIC3X codec. For example AM335X-EVM,
+         AM335X-EVMSK, and BeagelBone with AudioCape boards have this
+         setup.
+
 config SND_DAVINCI_SOC_EVM
        tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM"
        depends on SND_DAVINCI_SOC
index a396ab6d6d5efaa6f11ec5d1da6716cb4a1db0ac..bc81e79fc301b8357cddd5edf7e707beb33a0723 100644 (file)
@@ -13,6 +13,7 @@ obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o
 snd-soc-evm-objs := davinci-evm.o
 
 obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o
+obj-$(CONFIG_SND_AM33XX_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DA850_SOC_EVM) += snd-soc-evm.o
index fd7c45b9ed5a3836323a4d54af31df6f2929d050..623eb5e7c08981c08f31f2d51863c0426c1a7416 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/platform_data/edma.h>
 #include <linux/i2c.h>
+#include <linux/of_platform.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/soc.h>
 #include <asm/dma.h>
 #include <asm/mach-types.h>
 
+#include <linux/edma.h>
+
 #include "davinci-pcm.h"
 #include "davinci-i2s.h"
 #include "davinci-mcasp.h"
 
+struct snd_soc_card_drvdata_davinci {
+       unsigned sysclk;
+};
+
 #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \
                SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF)
 static int evm_hw_params(struct snd_pcm_substream *substream,
@@ -35,27 +42,11 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       struct snd_soc_codec *codec = rtd->codec;
+       struct snd_soc_card *soc_card = codec->card;
        int ret = 0;
-       unsigned sysclk;
-
-       /* ASP1 on DM355 EVM is clocked by an external oscillator */
-       if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() ||
-           machine_is_davinci_dm365_evm())
-               sysclk = 27000000;
-
-       /* ASP0 in DM6446 EVM is clocked by U55, as configured by
-        * board-dm644x-evm.c using GPIOs from U18.  There are six
-        * options; here we "know" we use a 48 KHz sample rate.
-        */
-       else if (machine_is_davinci_evm())
-               sysclk = 12288000;
-
-       else if (machine_is_davinci_da830_evm() ||
-                               machine_is_davinci_da850_evm())
-               sysclk = 24576000;
-
-       else
-               return -EINVAL;
+       unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *)
+                          snd_soc_card_get_drvdata(soc_card))->sysclk;
 
        /* set codec DAI configuration */
        ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
@@ -133,13 +124,22 @@ static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd)
 {
        struct snd_soc_codec *codec = rtd->codec;
        struct snd_soc_dapm_context *dapm = &codec->dapm;
+       struct device_node *np = codec->card->dev->of_node;
+       int ret;
 
        /* Add davinci-evm specific widgets */
        snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets,
                                  ARRAY_SIZE(aic3x_dapm_widgets));
 
-       /* Set up davinci-evm specific audio path audio_map */
-       snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
+       if (np) {
+               ret = snd_soc_of_parse_audio_routing(codec->card,
+                                                       "ti,audio-routing");
+               if (ret)
+                       return ret;
+       } else {
+               /* Set up davinci-evm specific audio path audio_map */
+               snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
+       }
 
        /* not connected */
        snd_soc_dapm_disable_pin(dapm, "MONO_LOUT");
@@ -243,35 +243,65 @@ static struct snd_soc_dai_link da850_evm_dai = {
 };
 
 /* davinci dm6446 evm audio machine driver */
+/*
+ * ASP0 in DM6446 EVM is clocked by U55, as configured by
+ * board-dm644x-evm.c using GPIOs from U18.  There are six
+ * options; here we "know" we use a 48 KHz sample rate.
+ */
+static struct snd_soc_card_drvdata_davinci dm6446_snd_soc_card_drvdata = {
+       .sysclk = 12288000,
+};
+
 static struct snd_soc_card dm6446_snd_soc_card_evm = {
        .name = "DaVinci DM6446 EVM",
        .owner = THIS_MODULE,
        .dai_link = &dm6446_evm_dai,
        .num_links = 1,
+       .drvdata = &dm6446_snd_soc_card_drvdata,
 };
 
 /* davinci dm355 evm audio machine driver */
+/* ASP1 on DM355 EVM is clocked by an external oscillator */
+static struct snd_soc_card_drvdata_davinci dm355_snd_soc_card_drvdata = {
+       .sysclk = 27000000,
+};
+
 static struct snd_soc_card dm355_snd_soc_card_evm = {
        .name = "DaVinci DM355 EVM",
        .owner = THIS_MODULE,
        .dai_link = &dm355_evm_dai,
        .num_links = 1,
+       .drvdata = &dm355_snd_soc_card_drvdata,
 };
 
 /* davinci dm365 evm audio machine driver */
+static struct snd_soc_card_drvdata_davinci dm365_snd_soc_card_drvdata = {
+       .sysclk = 27000000,
+};
+
 static struct snd_soc_card dm365_snd_soc_card_evm = {
        .name = "DaVinci DM365 EVM",
        .owner = THIS_MODULE,
        .dai_link = &dm365_evm_dai,
        .num_links = 1,
+       .drvdata = &dm365_snd_soc_card_drvdata,
 };
 
 /* davinci dm6467 evm audio machine driver */
+static struct snd_soc_card_drvdata_davinci dm6467_snd_soc_card_drvdata = {
+       .sysclk = 27000000,
+};
+
 static struct snd_soc_card dm6467_snd_soc_card_evm = {
        .name = "DaVinci DM6467 EVM",
        .owner = THIS_MODULE,
        .dai_link = dm6467_evm_dai,
        .num_links = ARRAY_SIZE(dm6467_evm_dai),
+       .drvdata = &dm6467_snd_soc_card_drvdata,
+};
+
+static struct snd_soc_card_drvdata_davinci da830_snd_soc_card_drvdata = {
+       .sysclk = 24576000,
 };
 
 static struct snd_soc_card da830_snd_soc_card = {
@@ -279,6 +309,11 @@ static struct snd_soc_card da830_snd_soc_card = {
        .owner = THIS_MODULE,
        .dai_link = &da830_evm_dai,
        .num_links = 1,
+       .drvdata = &da830_snd_soc_card_drvdata,
+};
+
+static struct snd_soc_card_drvdata_davinci da850_snd_soc_card_drvdata = {
+       .sysclk = 24576000,
 };
 
 static struct snd_soc_card da850_snd_soc_card = {
@@ -286,8 +321,101 @@ static struct snd_soc_card da850_snd_soc_card = {
        .owner = THIS_MODULE,
        .dai_link = &da850_evm_dai,
        .num_links = 1,
+       .drvdata = &da850_snd_soc_card_drvdata,
+};
+
+#if defined(CONFIG_OF)
+
+/*
+ * The struct is used as place holder. It will be completely
+ * filled with data from dt node.
+ */
+static struct snd_soc_dai_link evm_dai_tlv320aic3x = {
+       .name           = "TLV320AIC3X",
+       .stream_name    = "AIC3X",
+       .codec_dai_name = "tlv320aic3x-hifi",
+       .ops            = &evm_ops,
+       .init           = evm_aic3x_init,
+};
+
+static const struct of_device_id davinci_evm_dt_ids[] = {
+       {
+               .compatible = "ti,da830-evm-audio",
+               .data = (void *) &evm_dai_tlv320aic3x,
+       },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, davinci_evm_dt_ids);
+
+/* davinci evm audio machine driver */
+static struct snd_soc_card evm_soc_card = {
+       .owner = THIS_MODULE,
+       .num_links = 1,
 };
 
+static int davinci_evm_probe(struct platform_device *pdev)
+{
+       struct device_node *np = pdev->dev.of_node;
+       const struct of_device_id *match =
+               of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev);
+       struct snd_soc_dai_link *dai = (struct snd_soc_dai_link *) match->data;
+       struct snd_soc_card_drvdata_davinci *drvdata = NULL;
+       int ret = 0;
+
+       evm_soc_card.dai_link = dai;
+
+       dai->codec_of_node = of_parse_phandle(np, "ti,audio-codec", 0);
+       if (!dai->codec_of_node)
+               return -EINVAL;
+
+       dai->cpu_of_node = of_parse_phandle(np, "ti,mcasp-controller", 0);
+       if (!dai->cpu_of_node)
+               return -EINVAL;
+
+       dai->platform_of_node = dai->cpu_of_node;
+
+       evm_soc_card.dev = &pdev->dev;
+       ret = snd_soc_of_parse_card_name(&evm_soc_card, "ti,model");
+       if (ret)
+               return ret;
+
+       drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+       if (!drvdata)
+               return -ENOMEM;
+
+       ret = of_property_read_u32(np, "ti,codec-clock-rate", &drvdata->sysclk);
+       if (ret < 0)
+               return -EINVAL;
+
+       snd_soc_card_set_drvdata(&evm_soc_card, drvdata);
+       ret = devm_snd_soc_register_card(&pdev->dev, &evm_soc_card);
+
+       if (ret)
+               dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
+
+       return ret;
+}
+
+static int davinci_evm_remove(struct platform_device *pdev)
+{
+       struct snd_soc_card *card = platform_get_drvdata(pdev);
+
+       snd_soc_unregister_card(card);
+
+       return 0;
+}
+
+static struct platform_driver davinci_evm_driver = {
+       .probe          = davinci_evm_probe,
+       .remove         = davinci_evm_remove,
+       .driver         = {
+               .name   = "davinci_evm",
+               .owner  = THIS_MODULE,
+               .of_match_table = of_match_ptr(davinci_evm_dt_ids),
+       },
+};
+#endif
+
 static struct platform_device *evm_snd_device;
 
 static int __init evm_init(void)
@@ -296,6 +424,15 @@ static int __init evm_init(void)
        int index;
        int ret;
 
+       /*
+        * If dtb is there, the devices will be created dynamically.
+        * Only register platfrom driver structure.
+        */
+#if defined(CONFIG_OF)
+       if (of_have_populated_dt())
+               return platform_driver_register(&davinci_evm_driver);
+#endif
+
        if (machine_is_davinci_evm()) {
                evm_snd_dev_data = &dm6446_snd_soc_card_evm;
                index = 0;
@@ -331,6 +468,13 @@ static int __init evm_init(void)
 
 static void __exit evm_exit(void)
 {
+#if defined(CONFIG_OF)
+       if (of_have_populated_dt()) {
+               platform_driver_unregister(&davinci_evm_driver);
+               return;
+       }
+#endif
+
        platform_device_unregister(evm_snd_device);
 }
 
index 32ddb7fe5034865a7f13dc7243f1f8161482c7f2..71e14bb3a8cd11b4465567d088a05820e0ecdb74 100644 (file)
@@ -1001,18 +1001,40 @@ static const struct snd_soc_component_driver davinci_mcasp_component = {
        .name           = "davinci-mcasp",
 };
 
+/* Some HW specific values and defaults. The rest is filled in from DT. */
+static struct snd_platform_data dm646x_mcasp_pdata = {
+       .tx_dma_offset = 0x400,
+       .rx_dma_offset = 0x400,
+       .asp_chan_q = EVENTQ_0,
+       .version = MCASP_VERSION_1,
+};
+
+static struct snd_platform_data da830_mcasp_pdata = {
+       .tx_dma_offset = 0x2000,
+       .rx_dma_offset = 0x2000,
+       .asp_chan_q = EVENTQ_0,
+       .version = MCASP_VERSION_2,
+};
+
+static struct snd_platform_data omap2_mcasp_pdata = {
+       .tx_dma_offset = 0,
+       .rx_dma_offset = 0,
+       .asp_chan_q = EVENTQ_0,
+       .version = MCASP_VERSION_3,
+};
+
 static const struct of_device_id mcasp_dt_ids[] = {
        {
                .compatible = "ti,dm646x-mcasp-audio",
-               .data = (void *)MCASP_VERSION_1,
+               .data = &dm646x_mcasp_pdata,
        },
        {
                .compatible = "ti,da830-mcasp-audio",
-               .data = (void *)MCASP_VERSION_2,
+               .data = &da830_mcasp_pdata,
        },
        {
-               .compatible = "ti,omap2-mcasp-audio",
-               .data = (void *)MCASP_VERSION_3,
+               .compatible = "ti,am33xx-mcasp-audio",
+               .data = &omap2_mcasp_pdata,
        },
        { /* sentinel */ }
 };
@@ -1025,9 +1047,9 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
        struct snd_platform_data *pdata = NULL;
        const struct of_device_id *match =
                        of_match_device(mcasp_dt_ids, &pdev->dev);
+       struct of_phandle_args dma_spec;
 
        const u32 *of_serial_dir32;
-       u8 *of_serial_dir;
        u32 val;
        int i, ret = 0;
 
@@ -1035,20 +1057,13 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
                pdata = pdev->dev.platform_data;
                return pdata;
        } else if (match) {
-               pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
-               if (!pdata) {
-                       ret = -ENOMEM;
-                       goto nodata;
-               }
+               pdata = (struct snd_platform_data *) match->data;
        } else {
                /* control shouldn't reach here. something is wrong */
                ret = -EINVAL;
                goto nodata;
        }
 
-       if (match->data)
-               pdata->version = (u8)((int)match->data);
-
        ret = of_property_read_u32(np, "op-mode", &val);
        if (ret >= 0)
                pdata->op_mode = val;
@@ -1065,35 +1080,46 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
                pdata->tdm_slots = val;
        }
 
-       ret = of_property_read_u32(np, "num-serializer", &val);
-       if (ret >= 0)
-               pdata->num_serializer = val;
-
        of_serial_dir32 = of_get_property(np, "serial-dir", &val);
        val /= sizeof(u32);
-       if (val != pdata->num_serializer) {
-               dev_err(&pdev->dev,
-                               "num-serializer(%d) != serial-dir size(%d)\n",
-                               pdata->num_serializer, val);
-               ret = -EINVAL;
-               goto nodata;
-       }
-
        if (of_serial_dir32) {
-               of_serial_dir = devm_kzalloc(&pdev->dev,
-                                               (sizeof(*of_serial_dir) * val),
-                                               GFP_KERNEL);
+               u8 *of_serial_dir = devm_kzalloc(&pdev->dev,
+                                                (sizeof(*of_serial_dir) * val),
+                                                GFP_KERNEL);
                if (!of_serial_dir) {
                        ret = -ENOMEM;
                        goto nodata;
                }
 
-               for (i = 0; i < pdata->num_serializer; i++)
+               for (i = 0; i < val; i++)
                        of_serial_dir[i] = be32_to_cpup(&of_serial_dir32[i]);
 
+               pdata->num_serializer = val;
                pdata->serial_dir = of_serial_dir;
        }
 
+       ret = of_property_match_string(np, "dma-names", "tx");
+       if (ret < 0)
+               goto nodata;
+
+       ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret,
+                                        &dma_spec);
+       if (ret < 0)
+               goto nodata;
+
+       pdata->tx_dma_channel = dma_spec.args[0];
+
+       ret = of_property_match_string(np, "dma-names", "rx");
+       if (ret < 0)
+               goto nodata;
+
+       ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret,
+                                        &dma_spec);
+       if (ret < 0)
+               goto nodata;
+
+       pdata->rx_dma_channel = dma_spec.args[0];
+
        ret = of_property_read_u32(np, "tx-num-evt", &val);
        if (ret >= 0)
                pdata->txnumevt = val;
@@ -1124,7 +1150,7 @@ nodata:
 static int davinci_mcasp_probe(struct platform_device *pdev)
 {
        struct davinci_pcm_dma_params *dma_data;
-       struct resource *mem, *ioarea, *res;
+       struct resource *mem, *ioarea, *res, *dat;
        struct snd_platform_data *pdata;
        struct davinci_audio_dev *dev;
        int ret;
@@ -1145,10 +1171,15 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
        if (!mem) {
-               dev_err(&pdev->dev, "no mem resource?\n");
-               return -ENODEV;
+               dev_warn(dev->dev,
+                        "\"mpu\" mem resource not found, using index 0\n");
+               mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+               if (!mem) {
+                       dev_err(&pdev->dev, "no mem resource?\n");
+                       return -ENODEV;
+               }
        }
 
        ioarea = devm_request_mem_region(&pdev->dev, mem->start,
@@ -1182,40 +1213,36 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
        dev->rxnumevt = pdata->rxnumevt;
        dev->dev = &pdev->dev;
 
+       dat = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat");
+       if (!dat)
+               dat = mem;
+
        dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
        dma_data->asp_chan_q = pdata->asp_chan_q;
        dma_data->ram_chan_q = pdata->ram_chan_q;
        dma_data->sram_pool = pdata->sram_pool;
        dma_data->sram_size = pdata->sram_size_playback;
-       dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
-                                                       mem->start);
+       dma_data->dma_addr = dat->start + pdata->tx_dma_offset;
 
-       /* first TX, then RX */
        res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-       if (!res) {
-               dev_err(&pdev->dev, "no DMA resource\n");
-               ret = -ENODEV;
-               goto err_release_clk;
-       }
-
-       dma_data->channel = res->start;
+       if (res)
+               dma_data->channel = res->start;
+       else
+               dma_data->channel = pdata->tx_dma_channel;
 
        dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
        dma_data->asp_chan_q = pdata->asp_chan_q;
        dma_data->ram_chan_q = pdata->ram_chan_q;
        dma_data->sram_pool = pdata->sram_pool;
        dma_data->sram_size = pdata->sram_size_capture;
-       dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
-                                                       mem->start);
+       dma_data->dma_addr = dat->start + pdata->rx_dma_offset;
 
        res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-       if (!res) {
-               dev_err(&pdev->dev, "no DMA resource\n");
-               ret = -ENODEV;
-               goto err_release_clk;
-       }
+       if (res)
+               dma_data->channel = res->start;
+       else
+               dma_data->channel = pdata->rx_dma_channel;
 
-       dma_data->channel = res->start;
        dev_set_drvdata(&pdev->dev, dev);
        ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component,
                                         &davinci_mcasp_dai[pdata->op_mode], 1);
@@ -1251,12 +1278,51 @@ static int davinci_mcasp_remove(struct platform_device *pdev)
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int davinci_mcasp_suspend(struct device *dev)
+{
+       struct davinci_audio_dev *a = dev_get_drvdata(dev);
+       void __iomem *base = a->base;
+
+       a->context.txfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_TXFMCTL_REG);
+       a->context.rxfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_RXFMCTL_REG);
+       a->context.txfmt = mcasp_get_reg(base + DAVINCI_MCASP_TXFMT_REG);
+       a->context.rxfmt = mcasp_get_reg(base + DAVINCI_MCASP_RXFMT_REG);
+       a->context.aclkxctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKXCTL_REG);
+       a->context.aclkrctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKRCTL_REG);
+       a->context.pdir = mcasp_get_reg(base + DAVINCI_MCASP_PDIR_REG);
+
+       return 0;
+}
+
+static int davinci_mcasp_resume(struct device *dev)
+{
+       struct davinci_audio_dev *a = dev_get_drvdata(dev);
+       void __iomem *base = a->base;
+
+       mcasp_set_reg(base + DAVINCI_MCASP_TXFMCTL_REG, a->context.txfmtctl);
+       mcasp_set_reg(base + DAVINCI_MCASP_RXFMCTL_REG, a->context.rxfmtctl);
+       mcasp_set_reg(base + DAVINCI_MCASP_TXFMT_REG, a->context.txfmt);
+       mcasp_set_reg(base + DAVINCI_MCASP_RXFMT_REG, a->context.rxfmt);
+       mcasp_set_reg(base + DAVINCI_MCASP_ACLKXCTL_REG, a->context.aclkxctl);
+       mcasp_set_reg(base + DAVINCI_MCASP_ACLKRCTL_REG, a->context.aclkrctl);
+       mcasp_set_reg(base + DAVINCI_MCASP_PDIR_REG, a->context.pdir);
+
+       return 0;
+}
+#endif
+
+SIMPLE_DEV_PM_OPS(davinci_mcasp_pm_ops,
+                 davinci_mcasp_suspend,
+                 davinci_mcasp_resume);
+
 static struct platform_driver davinci_mcasp_driver = {
        .probe          = davinci_mcasp_probe,
        .remove         = davinci_mcasp_remove,
        .driver         = {
                .name   = "davinci-mcasp",
                .owner  = THIS_MODULE,
+               .pm     = &davinci_mcasp_pm_ops,
                .of_match_table = mcasp_dt_ids,
        },
 };
@@ -1266,4 +1332,3 @@ module_platform_driver(davinci_mcasp_driver);
 MODULE_AUTHOR("Steve Chen");
 MODULE_DESCRIPTION("TI DAVINCI McASP SoC Interface");
 MODULE_LICENSE("GPL");
-
index a9ac0c11da71dd784ed26286e46d064f0cca66c9..a2e27e1c32f3b28a8600ea0bb5325a35f7fe9741 100644 (file)
@@ -43,6 +43,18 @@ struct davinci_audio_dev {
        /* McASP FIFO related */
        u8      txnumevt;
        u8      rxnumevt;
+
+#ifdef CONFIG_PM_SLEEP
+       struct {
+               u32     txfmtctl;
+               u32     rxfmtctl;
+               u32     txfmt;
+               u32     rxfmt;
+               u32     aclkxctl;
+               u32     aclkrctl;
+               u32     pdir;
+       } context;
+#endif
 };
 
 #endif /* DAVINCI_MCASP_H */
index 3920c3e849ce4dfd6b76f77d877363243d8234d5..ff1f34766ee394119001f9bb417dbe3bf25d9ea3 100644 (file)
@@ -963,7 +963,7 @@ static bool fsl_spdif_readable_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg)
@@ -982,7 +982,7 @@ static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static const struct regmap_config fsl_spdif_regmap_config = {
@@ -1172,23 +1172,16 @@ static int fsl_spdif_probe(struct platform_device *pdev)
        /* Register with ASoC */
        dev_set_drvdata(&pdev->dev, spdif_priv);
 
-       ret = snd_soc_register_component(&pdev->dev, &fsl_spdif_component,
-                                        &spdif_priv->cpu_dai_drv, 1);
+       ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component,
+                                             &spdif_priv->cpu_dai_drv, 1);
        if (ret) {
                dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
                return ret;
        }
 
        ret = imx_pcm_dma_init(pdev);
-       if (ret) {
+       if (ret)
                dev_err(&pdev->dev, "imx_pcm_dma_init failed: %d\n", ret);
-               goto error_component;
-       }
-
-       return ret;
-
-error_component:
-       snd_soc_unregister_component(&pdev->dev);
 
        return ret;
 }
@@ -1196,7 +1189,6 @@ error_component:
 static int fsl_spdif_remove(struct platform_device *pdev)
 {
        imx_pcm_dma_exit(pdev);
-       snd_soc_unregister_component(&pdev->dev);
 
        return 0;
 }
index 6b81d0ce2c44ac637188fffdb67f10289f17f67a..35e277379b86ce80d56737e3e0c05a5b3772fb2c 100644 (file)
@@ -469,19 +469,12 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
                         * parameters, then the second stream may be
                         * constrained to the wrong sample rate or size.
                         */
-                       if (!first_runtime->sample_bits) {
-                               dev_err(substream->pcm->card->dev,
-                                       "set sample size in %s stream first\n",
-                                       substream->stream ==
-                                       SNDRV_PCM_STREAM_PLAYBACK
-                                       ? "capture" : "playback");
-                               return -EAGAIN;
-                       }
-
-                       snd_pcm_hw_constraint_minmax(substream->runtime,
-                               SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
+                       if (first_runtime->sample_bits) {
+                               snd_pcm_hw_constraint_minmax(substream->runtime,
+                                               SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
                                first_runtime->sample_bits,
                                first_runtime->sample_bits);
+                       }
                }
 
                ssi_private->second_stream = substream;
@@ -748,7 +741,7 @@ static void fsl_ssi_ac97_init(void)
        fsl_ssi_setup(fsl_ac97_data);
 }
 
-void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
+static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
                unsigned short val)
 {
        struct ccsr_ssi *ssi = fsl_ac97_data->ssi;
@@ -770,7 +763,7 @@ void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
        udelay(100);
 }
 
-unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
+static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
                unsigned short reg)
 {
        struct ccsr_ssi *ssi = fsl_ac97_data->ssi;
@@ -936,7 +929,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
        ssi_private->ssi_phys = res.start;
 
        ssi_private->irq = irq_of_parse_and_map(np, 0);
-       if (ssi_private->irq == 0) {
+       if (!ssi_private->irq) {
                dev_err(&pdev->dev, "no irq for node %s\n", np->full_name);
                return -ENXIO;
        }
@@ -1135,7 +1128,6 @@ static int fsl_ssi_remove(struct platform_device *pdev)
        if (ssi_private->ssi_on_imx)
                imx_pcm_dma_exit(pdev);
        snd_soc_unregister_component(&pdev->dev);
-       dev_set_drvdata(&pdev->dev, NULL);
        device_remove_file(&pdev->dev, &ssi_private->dev_attr);
        if (ssi_private->ssi_on_imx)
                clk_disable_unprepare(ssi_private->clk);
index d3bf71a0ec56aa6ff0ef604b36779eec79e3f23a..ac869931d7f16c9c4049aefaffb4a7d416417e49 100644 (file)
@@ -66,13 +66,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
                                size_t count, loff_t *ppos)
 {
        ssize_t ret;
-       char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+       char *buf;
        int port = (int)file->private_data;
        u32 pdcr, ptcr;
 
-       if (!buf)
-               return -ENOMEM;
-
        if (audmux_clk) {
                ret = clk_prepare_enable(audmux_clk);
                if (ret)
@@ -85,6 +82,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
        if (audmux_clk)
                clk_disable_unprepare(audmux_clk);
 
+       buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
        ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
                       pdcr, ptcr);
 
index a2fd7321b5a9a1bbd321f756af14fd9f071a372f..79cee782dbbf9184264e69383b6d5a5ff1ba0fd7 100644 (file)
@@ -160,6 +160,7 @@ static struct platform_driver imx_mc13783_audio_driver = {
        .driver = {
                .name = "imx_mc13783",
                .owner = THIS_MODULE,
+               .pm = &snd_soc_pm_ops,
        },
        .probe = imx_mc13783_probe,
        .remove = imx_mc13783_remove
index 4dc1296688e9210531f904366dcc19603e0022ce..aee23077080a219983f0dd52764d1aa4199cb15c 100644 (file)
 
 static bool filter(struct dma_chan *chan, void *param)
 {
-       struct snd_dmaengine_dai_dma_data *dma_data = param;
-
        if (!imx_dma_is_general_purpose(chan))
                return false;
 
-       chan->private = dma_data->filter_data;
+       chan->private = param;
 
        return true;
 }
index ca1be1d9dcf0349b608f77367f5330ca7c2c6308..f2beae78969f6dd8e03125f92e3f288a8776f411 100644 (file)
@@ -159,7 +159,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
        data->card.dapm_widgets = imx_sgtl5000_dapm_widgets;
        data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets);
 
-       ret = snd_soc_register_card(&data->card);
+       ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
                goto fail;
@@ -186,7 +186,6 @@ static int imx_sgtl5000_remove(struct platform_device *pdev)
 {
        struct imx_sgtl5000_data *data = platform_get_drvdata(pdev);
 
-       snd_soc_unregister_card(&data->card);
        clk_put(data->codec_clk);
 
        return 0;
@@ -202,6 +201,7 @@ static struct platform_driver imx_sgtl5000_driver = {
        .driver = {
                .name = "imx-sgtl5000",
                .owner = THIS_MODULE,
+               .pm = &snd_soc_pm_ops,
                .of_match_table = imx_sgtl5000_dt_ids,
        },
        .probe = imx_sgtl5000_probe,
index 816013b0ebba4f0b16e3fdfddd0e763833d1ee39..8499d5292f088a45e9ea736106ee2db13e7d205a 100644 (file)
@@ -87,7 +87,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev)
        if (ret)
                goto error_dir;
 
-       ret = snd_soc_register_card(&data->card);
+       ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret);
                goto error_dir;
@@ -119,8 +119,6 @@ static int imx_spdif_audio_remove(struct platform_device *pdev)
        if (data->txdev)
                platform_device_unregister(data->txdev);
 
-       snd_soc_unregister_card(&data->card);
-
        return 0;
 }
 
index 57d6941676ffabc509754317337bf109e16376a3..f5f248c91c16db7c3db5a50654bceedb0e81953f 100644 (file)
@@ -613,7 +613,6 @@ static int imx_ssi_probe(struct platform_device *pdev)
 failed_pcm:
        snd_soc_unregister_component(&pdev->dev);
 failed_register:
-       release_mem_region(res->start, resource_size(res));
        clk_disable_unprepare(ssi->clk);
 failed_clk:
        snd_soc_set_ac97_ops(NULL);
@@ -623,7 +622,6 @@ failed_clk:
 
 static int imx_ssi_remove(struct platform_device *pdev)
 {
-       struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        struct imx_ssi *ssi = platform_get_drvdata(pdev);
 
        if (!ssi->dma_init)
@@ -637,7 +635,6 @@ static int imx_ssi_remove(struct platform_device *pdev)
        if (ssi->flags & IMX_SSI_USE_AC97)
                ac97_ssi = NULL;
 
-       release_mem_region(res->start, resource_size(res));
        clk_disable_unprepare(ssi->clk);
        snd_soc_set_ac97_ops(NULL);
 
index 722afe69169e904798974115292159a89a08ba18..72064e995687fc922a4adb3f6f3b9211c13107b7 100644 (file)
@@ -266,7 +266,7 @@ static int imx_wm8962_probe(struct platform_device *pdev)
        data->card.late_probe = imx_wm8962_late_probe;
        data->card.set_bias_level = imx_wm8962_set_bias_level;
 
-       ret = snd_soc_register_card(&data->card);
+       ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
                goto clk_fail;
@@ -296,7 +296,6 @@ static int imx_wm8962_remove(struct platform_device *pdev)
 
        if (!IS_ERR(data->codec_clk))
                clk_disable_unprepare(data->codec_clk);
-       snd_soc_unregister_card(&data->card);
 
        return 0;
 }
@@ -311,6 +310,7 @@ static struct platform_driver imx_wm8962_driver = {
        .driver = {
                .name = "imx-wm8962",
                .owner = THIS_MODULE,
+               .pm = &snd_soc_pm_ops,
                .of_match_table = imx_wm8962_dt_ids,
        },
        .probe = imx_wm8962_probe,
index 8c49147db84c43cf73d5870a4802959e66330ce2..b2fbb7075a6c9900aac6aea847b63242a359a5a7 100644 (file)
@@ -27,6 +27,11 @@ static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
        if (!ret && daifmt)
                ret = snd_soc_dai_set_fmt(dai, daifmt);
 
+       if (ret == -ENOTSUPP) {
+               dev_dbg(dai->dev, "ASoC: set_fmt is not supported\n");
+               ret = 0;
+       }
+
        if (!ret && set->sysclk)
                ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0);
 
index b238434f92b099db8bf3ba613fc596b7006ec96d..55d0d9d3a9fdda319773551674b01e8bd6775e20 100644 (file)
@@ -29,9 +29,7 @@
 #define KIRKWOOD_FORMATS \
        (SNDRV_PCM_FMTBIT_S16_LE | \
         SNDRV_PCM_FMTBIT_S24_LE | \
-        SNDRV_PCM_FMTBIT_S32_LE | \
-        SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | \
-        SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE)
+        SNDRV_PCM_FMTBIT_S32_LE)
 
 static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs)
 {
@@ -161,7 +159,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
                 * Enable Error interrupts. We're only ack'ing them but
                 * it's useful for diagnostics
                 */
-               writel((unsigned long)-1, priv->io + KIRKWOOD_ERR_MASK);
+               writel((unsigned int)-1, priv->io + KIRKWOOD_ERR_MASK);
        }
 
        dram = mv_mbus_dram_info();
index 0f3d73d4ef48ea72d5d9b3c63d72f90e919ba7bc..9ec38d15df9eb1b7d53976fe568c6ec1952d58a5 100644 (file)
@@ -103,7 +103,7 @@ static void kirkwood_set_rate(struct snd_soc_dai *dai,
 {
        uint32_t clks_ctrl;
 
-       if (rate == 44100 || rate == 48000 || rate == 96000) {
+       if (IS_ERR(priv->extclk)) {
                /* use internal dco for the supported rates
                 * defined in kirkwood_i2s_dai */
                dev_dbg(dai->dev, "%s: dco set rate = %lu\n",
@@ -160,9 +160,11 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream,
        case SNDRV_PCM_FORMAT_S16_LE:
                i2s_value |= KIRKWOOD_I2S_CTL_SIZE_16;
                ctl_play = KIRKWOOD_PLAYCTL_SIZE_16_C |
-                          KIRKWOOD_PLAYCTL_I2S_EN;
+                          KIRKWOOD_PLAYCTL_I2S_EN |
+                          KIRKWOOD_PLAYCTL_SPDIF_EN;
                ctl_rec = KIRKWOOD_RECCTL_SIZE_16_C |
-                         KIRKWOOD_RECCTL_I2S_EN;
+                         KIRKWOOD_RECCTL_I2S_EN |
+                         KIRKWOOD_RECCTL_SPDIF_EN;
                break;
        /*
         * doesn't work... S20_3LE != kirkwood 20bit format ?
@@ -178,9 +180,11 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream,
        case SNDRV_PCM_FORMAT_S24_LE:
                i2s_value |= KIRKWOOD_I2S_CTL_SIZE_24;
                ctl_play = KIRKWOOD_PLAYCTL_SIZE_24 |
-                          KIRKWOOD_PLAYCTL_I2S_EN;
+                          KIRKWOOD_PLAYCTL_I2S_EN |
+                          KIRKWOOD_PLAYCTL_SPDIF_EN;
                ctl_rec = KIRKWOOD_RECCTL_SIZE_24 |
-                         KIRKWOOD_RECCTL_I2S_EN;
+                         KIRKWOOD_RECCTL_I2S_EN |
+                         KIRKWOOD_RECCTL_SPDIF_EN;
                break;
        case SNDRV_PCM_FORMAT_S32_LE:
                i2s_value |= KIRKWOOD_I2S_CTL_SIZE_32;
@@ -240,6 +244,11 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
                                   ctl);
        }
 
+       if (dai->id == 0)
+               ctl &= ~KIRKWOOD_PLAYCTL_SPDIF_EN;      /* i2s */
+       else
+               ctl &= ~KIRKWOOD_PLAYCTL_I2S_EN;        /* spdif */
+
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
                /* configure */
@@ -258,7 +267,8 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
 
        case SNDRV_PCM_TRIGGER_STOP:
                /* stop audio, disable interrupts */
-               ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE;
+               ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE |
+                               KIRKWOOD_PLAYCTL_SPDIF_MUTE;
                writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
 
                value = readl(priv->io + KIRKWOOD_INT_MASK);
@@ -272,13 +282,15 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
 
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
        case SNDRV_PCM_TRIGGER_SUSPEND:
-               ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE;
+               ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE |
+                               KIRKWOOD_PLAYCTL_SPDIF_MUTE;
                writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
                break;
 
        case SNDRV_PCM_TRIGGER_RESUME:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-               ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE);
+               ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE |
+                               KIRKWOOD_PLAYCTL_SPDIF_MUTE);
                writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
                break;
 
@@ -301,7 +313,13 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream,
        case SNDRV_PCM_TRIGGER_START:
                /* configure */
                ctl = priv->ctl_rec;
-               value = ctl & ~KIRKWOOD_RECCTL_I2S_EN;
+               if (dai->id == 0)
+                       ctl &= ~KIRKWOOD_RECCTL_SPDIF_EN;       /* i2s */
+               else
+                       ctl &= ~KIRKWOOD_RECCTL_I2S_EN;         /* spdif */
+
+               value = ctl & ~(KIRKWOOD_RECCTL_I2S_EN |
+                               KIRKWOOD_RECCTL_SPDIF_EN);
                writel(value, priv->io + KIRKWOOD_RECCTL);
 
                /* enable interrupts */
@@ -361,9 +379,8 @@ static int kirkwood_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
        return 0;
 }
 
-static int kirkwood_i2s_probe(struct snd_soc_dai *dai)
+static int kirkwood_i2s_init(struct kirkwood_dma_data *priv)
 {
-       struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
        unsigned long value;
        unsigned int reg_data;
 
@@ -404,9 +421,10 @@ static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = {
        .set_fmt        = kirkwood_i2s_set_fmt,
 };
 
-
-static struct snd_soc_dai_driver kirkwood_i2s_dai = {
-       .probe = kirkwood_i2s_probe,
+static struct snd_soc_dai_driver kirkwood_i2s_dai[2] = {
+    {
+       .name = "i2s",
+       .id = 0,
        .playback = {
                .channels_min = 1,
                .channels_max = 2,
@@ -422,10 +440,53 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai = {
                .formats = KIRKWOOD_I2S_FORMATS,
        },
        .ops = &kirkwood_i2s_dai_ops,
+    },
+    {
+       .name = "spdif",
+       .id = 1,
+       .playback = {
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
+                               SNDRV_PCM_RATE_96000,
+               .formats = KIRKWOOD_I2S_FORMATS,
+       },
+       .capture = {
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
+                               SNDRV_PCM_RATE_96000,
+               .formats = KIRKWOOD_I2S_FORMATS,
+       },
+       .ops = &kirkwood_i2s_dai_ops,
+    },
 };
 
-static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = {
-       .probe = kirkwood_i2s_probe,
+static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = {
+    {
+       .name = "i2s",
+       .id = 0,
+       .playback = {
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = SNDRV_PCM_RATE_8000_192000 |
+                        SNDRV_PCM_RATE_CONTINUOUS |
+                        SNDRV_PCM_RATE_KNOT,
+               .formats = KIRKWOOD_I2S_FORMATS,
+       },
+       .capture = {
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = SNDRV_PCM_RATE_8000_192000 |
+                        SNDRV_PCM_RATE_CONTINUOUS |
+                        SNDRV_PCM_RATE_KNOT,
+               .formats = KIRKWOOD_I2S_FORMATS,
+       },
+       .ops = &kirkwood_i2s_dai_ops,
+    },
+    {
+       .name = "spdif",
+       .id = 1,
        .playback = {
                .channels_min = 1,
                .channels_max = 2,
@@ -443,6 +504,7 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = {
                .formats = KIRKWOOD_I2S_FORMATS,
        },
        .ops = &kirkwood_i2s_dai_ops,
+    },
 };
 
 static const struct snd_soc_component_driver kirkwood_i2s_component = {
@@ -452,7 +514,7 @@ static const struct snd_soc_component_driver kirkwood_i2s_component = {
 static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 {
        struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data;
-       struct snd_soc_dai_driver *soc_dai = &kirkwood_i2s_dai;
+       struct snd_soc_dai_driver *soc_dai = kirkwood_i2s_dai;
        struct kirkwood_dma_data *priv;
        struct resource *mem;
        struct device_node *np = pdev->dev.of_node;
@@ -496,7 +558,10 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
                return err;
 
        priv->extclk = devm_clk_get(&pdev->dev, "extclk");
-       if (!IS_ERR(priv->extclk)) {
+       if (IS_ERR(priv->extclk)) {
+               if (PTR_ERR(priv->extclk) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+       } else {
                if (priv->extclk == priv->clk) {
                        devm_clk_put(&pdev->dev, priv->extclk);
                        priv->extclk = ERR_PTR(-EINVAL);
@@ -521,7 +586,7 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
        }
 
        err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component,
-                                        soc_dai, 1);
+                                        soc_dai, 2);
        if (err) {
                dev_err(&pdev->dev, "snd_soc_register_component failed\n");
                goto err_component;
@@ -532,6 +597,9 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "snd_soc_register_platform failed\n");
                goto err_platform;
        }
+
+       kirkwood_i2s_init(priv);
+
        return 0;
  err_platform:
        snd_soc_unregister_component(&pdev->dev);
index 025be0e97164283cbd4ed7516a477bb15bee404b..65f2a5b9ec3b5edcf4a37b80e7644ecf10137585 100644 (file)
@@ -52,7 +52,7 @@ static struct snd_soc_dai_link openrd_client_dai[] = {
 {
        .name = "CS42L51",
        .stream_name = "CS42L51 HiFi",
-       .cpu_dai_name = "mvebu-audio",
+       .cpu_dai_name = "i2s",
        .platform_name = "mvebu-audio",
        .codec_dai_name = "cs42l51-hifi",
        .codec_name = "cs42l51-codec.0-004a",
index 27545b0c48561470e787c3c167c60514172f10aa..d213832b0c72ee38b6ccf6f5c49867d6a8294888 100644 (file)
@@ -68,7 +68,7 @@ static struct snd_soc_dai_link t5325_dai[] = {
 {
        .name = "ALC5621",
        .stream_name = "ALC5621 HiFi",
-       .cpu_dai_name = "mvebu-audio",
+       .cpu_dai_name = "i2s",
        .platform_name = "mvebu-audio",
        .codec_dai_name = "alc5621-hifi",
        .codec_name = "alc562x-codec.0-001a",
index f8e1ccc1c58cc76f8ce2a314a1c8a0fcc5e998a5..bf23afbba1d7ba3d6e5e8f3bb22f078e5b2908ae 100644 (file)
 /* need to find where they come from               */
 #define KIRKWOOD_SND_MIN_PERIODS               8
 #define KIRKWOOD_SND_MAX_PERIODS               16
-#define KIRKWOOD_SND_MIN_PERIOD_BYTES          0x4000
-#define KIRKWOOD_SND_MAX_PERIOD_BYTES          0x4000
+#define KIRKWOOD_SND_MIN_PERIOD_BYTES          0x800
+#define KIRKWOOD_SND_MAX_PERIOD_BYTES          0x8000
 #define KIRKWOOD_SND_MAX_BUFFER_BYTES          (KIRKWOOD_SND_MAX_PERIOD_BYTES \
                                                 * KIRKWOOD_SND_MAX_PERIODS)
 
index ee363845759eca555346193ce17d740868d5fd6d..d3d4c32434f7614d944296b34b9b87f6c80a66b3 100644 (file)
@@ -400,7 +400,7 @@ static int snd_mfld_mc_probe(struct platform_device *pdev)
        }
        /* register the soc card */
        snd_soc_card_mfld.dev = &pdev->dev;
-       ret_val = snd_soc_register_card(&snd_soc_card_mfld);
+       ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_mfld);
        if (ret_val) {
                pr_debug("snd_soc_register_card failed %d\n", ret_val);
                return ret_val;
@@ -410,20 +410,12 @@ static int snd_mfld_mc_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int snd_mfld_mc_remove(struct platform_device *pdev)
-{
-       pr_debug("snd_mfld_mc_remove called\n");
-       snd_soc_unregister_card(&snd_soc_card_mfld);
-       return 0;
-}
-
 static struct platform_driver snd_mfld_mc_driver = {
        .driver = {
                .owner = THIS_MODULE,
                .name = "msic_audio",
        },
        .probe = snd_mfld_mc_probe,
-       .remove = snd_mfld_mc_remove,
 };
 
 module_platform_driver(snd_mfld_mc_driver);
index b56b8a0e8deb43b6fdca0668fb43677bb1ce47ba..54e622acac330d82a92d95164ae79e89cfb461e4 100644 (file)
@@ -494,6 +494,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
        struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai);
        struct mxs_saif *master_saif;
        u32 delay;
+       int ret;
 
        master_saif = mxs_saif_get_master(saif);
        if (!master_saif)
@@ -503,23 +504,37 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+               if (saif->state == MXS_SAIF_STATE_RUNNING)
+                       return 0;
+
                dev_dbg(cpu_dai->dev, "start\n");
 
-               clk_enable(master_saif->clk);
-               if (!master_saif->mclk_in_use)
-                       __raw_writel(BM_SAIF_CTRL_RUN,
-                               master_saif->base + SAIF_CTRL + MXS_SET_ADDR);
+               ret = clk_enable(master_saif->clk);
+               if (ret) {
+                       dev_err(saif->dev, "Failed to enable master clock\n");
+                       return ret;
+               }
 
                /*
                 * If the saif's master is not himself, we also need to enable
                 * itself clk for its internal basic logic to work.
                 */
                if (saif != master_saif) {
-                       clk_enable(saif->clk);
+                       ret = clk_enable(saif->clk);
+                       if (ret) {
+                               dev_err(saif->dev, "Failed to enable master clock\n");
+                               clk_disable(master_saif->clk);
+                               return ret;
+                       }
+
                        __raw_writel(BM_SAIF_CTRL_RUN,
                                saif->base + SAIF_CTRL + MXS_SET_ADDR);
                }
 
+               if (!master_saif->mclk_in_use)
+                       __raw_writel(BM_SAIF_CTRL_RUN,
+                               master_saif->base + SAIF_CTRL + MXS_SET_ADDR);
+
                if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                        /*
                         * write data to saif data register to trigger
@@ -543,6 +558,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
                }
 
                master_saif->ongoing = 1;
+               saif->state = MXS_SAIF_STATE_RUNNING;
 
                dev_dbg(saif->dev, "CTRL 0x%x STAT 0x%x\n",
                        __raw_readl(saif->base + SAIF_CTRL),
@@ -555,6 +571,9 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
        case SNDRV_PCM_TRIGGER_SUSPEND:
        case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+               if (saif->state == MXS_SAIF_STATE_STOPPED)
+                       return 0;
+
                dev_dbg(cpu_dai->dev, "stop\n");
 
                /* wait a while for the current sample to complete */
@@ -575,6 +594,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
                }
 
                master_saif->ongoing = 0;
+               saif->state = MXS_SAIF_STATE_STOPPED;
 
                break;
        default:
@@ -768,8 +788,8 @@ static int mxs_saif_probe(struct platform_device *pdev)
                        dev_warn(&pdev->dev, "failed to init clocks\n");
        }
 
-       ret = snd_soc_register_component(&pdev->dev, &mxs_saif_component,
-                                        &mxs_saif_dai, 1);
+       ret = devm_snd_soc_register_component(&pdev->dev, &mxs_saif_component,
+                                             &mxs_saif_dai, 1);
        if (ret) {
                dev_err(&pdev->dev, "register DAI failed\n");
                return ret;
@@ -778,21 +798,15 @@ static int mxs_saif_probe(struct platform_device *pdev)
        ret = mxs_pcm_platform_register(&pdev->dev);
        if (ret) {
                dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
-               goto failed_pdev_alloc;
+               return ret;
        }
 
        return 0;
-
-failed_pdev_alloc:
-       snd_soc_unregister_component(&pdev->dev);
-
-       return ret;
 }
 
 static int mxs_saif_remove(struct platform_device *pdev)
 {
        mxs_pcm_platform_unregister(&pdev->dev);
-       snd_soc_unregister_component(&pdev->dev);
 
        return 0;
 }
index 53eaa4bf0e2726b04c593d9c083895aece2becd6..fbaf7badfdfb03b7d26eb84fd5c1be5850d06d1a 100644 (file)
@@ -124,6 +124,11 @@ struct mxs_saif {
 
        u32 fifo_underrun;
        u32 fifo_overrun;
+
+       enum {
+               MXS_SAIF_STATE_STOPPED,
+               MXS_SAIF_STATE_RUNNING,
+       } state;
 };
 
 extern int mxs_saif_put_mclk(unsigned int saif_id);
index 4bb273786ff336aef16c08122915520f69467ef6..61822cc53bd3e9b53b63042dd6ea986b681a7d1b 100644 (file)
@@ -122,14 +122,12 @@ static struct snd_soc_card mxs_sgtl5000 = {
        .num_links      = ARRAY_SIZE(mxs_sgtl5000_dai),
 };
 
-static int mxs_sgtl5000_probe_dt(struct platform_device *pdev)
+static int mxs_sgtl5000_probe(struct platform_device *pdev)
 {
+       struct snd_soc_card *card = &mxs_sgtl5000;
+       int ret, i;
        struct device_node *np = pdev->dev.of_node;
        struct device_node *saif_np[2], *codec_np;
-       int i;
-
-       if (!np)
-               return 1; /* no device tree */
 
        saif_np[0] = of_parse_phandle(np, "saif-controllers", 0);
        saif_np[1] = of_parse_phandle(np, "saif-controllers", 1);
@@ -152,18 +150,6 @@ static int mxs_sgtl5000_probe_dt(struct platform_device *pdev)
        of_node_put(saif_np[0]);
        of_node_put(saif_np[1]);
 
-       return 0;
-}
-
-static int mxs_sgtl5000_probe(struct platform_device *pdev)
-{
-       struct snd_soc_card *card = &mxs_sgtl5000;
-       int ret;
-
-       ret = mxs_sgtl5000_probe_dt(pdev);
-       if (ret < 0)
-               return ret;
-
        /*
         * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w).
         * The Sgtl5000 sysclk is derived from saif0 mclk and it's range
index 90d2a7cd2563d06170d450b5bb6a9cc8a6615210..cd9ee167959dcc0b34512ffdf32d26208d506c31 100644 (file)
@@ -490,14 +490,9 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
 
        mcpdm->dev = &pdev->dev;
 
-       return snd_soc_register_component(&pdev->dev, &omap_mcpdm_component,
-                                         &omap_mcpdm_dai, 1);
-}
-
-static int asoc_mcpdm_remove(struct platform_device *pdev)
-{
-       snd_soc_unregister_component(&pdev->dev);
-       return 0;
+       return devm_snd_soc_register_component(&pdev->dev,
+                                              &omap_mcpdm_component,
+                                              &omap_mcpdm_dai, 1);
 }
 
 static const struct of_device_id omap_mcpdm_of_match[] = {
@@ -514,7 +509,6 @@ static struct platform_driver asoc_mcpdm_driver = {
        },
 
        .probe  = asoc_mcpdm_probe,
-       .remove = asoc_mcpdm_remove,
 };
 
 module_platform_driver(asoc_mcpdm_driver);
index 2a9324f794d8468172637ff07d28537a4a4cdd11..6a8d6b5f160debac623f79ad72b91dd5c77b1550 100644 (file)
@@ -338,9 +338,9 @@ static int omap_twl4030_probe(struct platform_device *pdev)
        }
 
        snd_soc_card_set_drvdata(card, priv);
-       ret = snd_soc_register_card(card);
+       ret = devm_snd_soc_register_card(&pdev->dev, card);
        if (ret) {
-               dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
+               dev_err(&pdev->dev, "devm_snd_soc_register_card() failed: %d\n",
                        ret);
                return ret;
        }
@@ -357,7 +357,6 @@ static int omap_twl4030_remove(struct platform_device *pdev)
                snd_soc_jack_free_gpios(&priv->hs_jack,
                                        ARRAY_SIZE(hs_jack_gpios),
                                        hs_jack_gpios);
-       snd_soc_unregister_card(card);
 
        return 0;
 }
index 5b7d969f89a96eebd418687ef5b7abc79d74ee97..08acdc236bf8479259b33068716c21ac5aace275 100644 (file)
@@ -163,6 +163,7 @@ static struct platform_driver mmp_driver = {
        .driver         = {
                .name   = "brownstone-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = brownstone_probe,
        .remove         = brownstone_remove,
index f4cce1e8011242364807ebe21dc15b74acb1e3c7..1853d41034bfa0c17d752f6191e4346e1cc06725 100644 (file)
@@ -329,6 +329,7 @@ static struct platform_driver corgi_driver = {
        .driver         = {
                .name   = "corgi-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = corgi_probe,
        .remove         = corgi_remove,
index 70d799b13f0d3fed2464c61046eb3e7439ebd8e4..44b5c09d296be62889649c5157dd098d12013deb 100644 (file)
@@ -178,6 +178,7 @@ static struct platform_driver e740_driver = {
        .driver         = {
                .name   = "e740-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = e740_probe,
        .remove         = e740_remove,
index f94d2ab51351b63932ff6e62d434cb08671dcc54..c34e447eb9911202ca5b6fbcaa78704f1103468a 100644 (file)
@@ -160,6 +160,7 @@ static struct platform_driver e750_driver = {
        .driver         = {
                .name   = "e750-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = e750_probe,
        .remove         = e750_remove,
index 8768a640dd71953a0c78b43d0df539d0b5c6ad18..3137f800b43f139a2c41adcfb3edc7981aae347a 100644 (file)
@@ -150,6 +150,7 @@ static struct platform_driver e800_driver = {
        .driver         = {
                .name   = "e800-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = e800_probe,
        .remove         = e800_remove,
index eef1f7b7b38e27c9ffcfb1b340df0f66d3173275..fd2f4eda1fd3f88d3945168f26fc6f5c57616506 100644 (file)
@@ -91,6 +91,7 @@ static struct platform_driver imote2_driver = {
        .driver         = {
                .name   = "imote2-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = imote2_probe,
        .remove         = imote2_remove,
index bbea7780eac640630803a024d3d0670b01c3c1eb..160c5245448f1e32303b240e47ab1e4616c25325 100644 (file)
@@ -215,6 +215,7 @@ static struct platform_driver mioa701_wm9713_driver = {
        .driver         = {
                .name           = "mioa701-wm9713",
                .owner          = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
 };
 
index 41752a5fe3b07148c5402b2ea66d6f292fdc3133..5bf5f1f7cac5013f461657e0487687ce597a485b 100644 (file)
@@ -455,8 +455,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
        priv->dai_fmt = (unsigned int) -1;
        platform_set_drvdata(pdev, priv);
 
-       return snd_soc_register_component(&pdev->dev, &mmp_sspa_component,
-                                         &mmp_sspa_dai, 1);
+       return devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component,
+                                              &mmp_sspa_dai, 1);
 }
 
 static int asoc_mmp_sspa_remove(struct platform_device *pdev)
@@ -466,7 +466,6 @@ static int asoc_mmp_sspa_remove(struct platform_device *pdev)
        clk_disable(priv->audio_clk);
        clk_put(priv->audio_clk);
        clk_put(priv->sysclk);
-       snd_soc_unregister_component(&pdev->dev);
        return 0;
 }
 
index e1ffcdd9a6492678c604ab045a7a981cae562971..3284c4b901cbfa740e75d633ddb1580698fdafb5 100644 (file)
@@ -181,6 +181,7 @@ static struct platform_driver palm27x_wm9712_driver = {
        .driver         = {
                .name           = "palm27x-asoc",
                .owner          = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
 };
 
index fafe46355c316b20df0f1e3fb114cae8d4cae9e2..c93e138d8dc3403f538c193d2bc1fc52794d9ad6 100644 (file)
@@ -303,6 +303,7 @@ static struct platform_driver poodle_driver = {
        .driver         = {
                .name   = "poodle-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = poodle_probe,
        .remove         = poodle_remove,
index f1059d999de6d4128791861d2325cd8bf68371dd..ae956e3f4b9dbfb0aea905e74b4c06cc25217291 100644 (file)
@@ -89,33 +89,6 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = {
        .filter_data    = &pxa2xx_ac97_pcm_aux_mic_mono_req,
 };
 
-#ifdef CONFIG_PM
-static int pxa2xx_ac97_suspend(struct snd_soc_dai *dai)
-{
-       return pxa2xx_ac97_hw_suspend();
-}
-
-static int pxa2xx_ac97_resume(struct snd_soc_dai *dai)
-{
-       return pxa2xx_ac97_hw_resume();
-}
-
-#else
-#define pxa2xx_ac97_suspend    NULL
-#define pxa2xx_ac97_resume     NULL
-#endif
-
-static int pxa2xx_ac97_probe(struct snd_soc_dai *dai)
-{
-       return pxa2xx_ac97_hw_probe(to_platform_device(dai->dev));
-}
-
-static int pxa2xx_ac97_remove(struct snd_soc_dai *dai)
-{
-       pxa2xx_ac97_hw_remove(to_platform_device(dai->dev));
-       return 0;
-}
-
 static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream,
                                 struct snd_pcm_hw_params *params,
                                 struct snd_soc_dai *cpu_dai)
@@ -185,10 +158,6 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = {
 {
        .name = "pxa2xx-ac97",
        .ac97_control = 1,
-       .probe = pxa2xx_ac97_probe,
-       .remove = pxa2xx_ac97_remove,
-       .suspend = pxa2xx_ac97_suspend,
-       .resume = pxa2xx_ac97_resume,
        .playback = {
                .stream_name = "AC97 Playback",
                .channels_min = 2,
@@ -246,6 +215,12 @@ static int pxa2xx_ac97_dev_probe(struct platform_device *pdev)
                return -ENXIO;
        }
 
+       ret = pxa2xx_ac97_hw_probe(pdev);
+       if (ret) {
+               dev_err(&pdev->dev, "PXA2xx AC97 hw probe error (%d)\n", ret);
+               return ret;
+       }
+
        ret = snd_soc_set_ac97_ops(&pxa2xx_ac97_ops);
        if (ret != 0)
                return ret;
@@ -262,15 +237,34 @@ static int pxa2xx_ac97_dev_remove(struct platform_device *pdev)
 {
        snd_soc_unregister_component(&pdev->dev);
        snd_soc_set_ac97_ops(NULL);
+       pxa2xx_ac97_hw_remove(pdev);
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int pxa2xx_ac97_dev_suspend(struct device *dev)
+{
+       return pxa2xx_ac97_hw_suspend();
+}
+
+static int pxa2xx_ac97_dev_resume(struct device *dev)
+{
+       return pxa2xx_ac97_hw_resume();
+}
+
+static SIMPLE_DEV_PM_OPS(pxa2xx_ac97_pm_ops,
+               pxa2xx_ac97_dev_suspend, pxa2xx_ac97_dev_resume);
+#endif
+
 static struct platform_driver pxa2xx_ac97_driver = {
        .probe          = pxa2xx_ac97_dev_probe,
        .remove         = pxa2xx_ac97_dev_remove,
        .driver         = {
                .name   = "pxa2xx-ac97",
                .owner  = THIS_MODULE,
+#ifdef CONFIG_PM_SLEEP
+               .pm     = &pxa2xx_ac97_pm_ops,
+#endif
        },
 };
 
index a3fe19123f07218bbd8af8bb7bd1cf6a26af8067..1d9c2ed223bc089b233b748485c7b5a2e387ee49 100644 (file)
@@ -275,6 +275,7 @@ static struct platform_driver tosa_driver = {
        .driver         = {
                .name   = "tosa-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = tosa_probe,
        .remove         = tosa_remove,
index 13c9ee0cb83b988b06cb9b84963128b1cd703032..0b535b570622d3ad1fcffef4a6be13753f817385 100644 (file)
@@ -160,6 +160,7 @@ static struct platform_driver ttc_dkb_driver = {
        .driver         = {
                .name   = "ttc-dkb-audio",
                .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = ttc_dkb_probe,
        .remove         = ttc_dkb_remove,
index 29e246803626baf1ba32f066226e1902cb7e1a86..84f5d8b766791748ca065678d828e767b27f0eb3 100644 (file)
@@ -356,6 +356,7 @@ static struct snd_soc_dapm_widget bells_widgets[] = {
 
 static struct snd_soc_dapm_route bells_routes[] = {
        { "Sub CLK_SYS", NULL, "OPCLK" },
+       { "CLKIN", NULL, "OPCLK" },
 
        { "DMIC", NULL, "MICBIAS2" },
        { "IN2L", NULL, "DMIC" },
index b302f3b7a587f3e480586419affc8e300c80ad8d..2c4d2505a19e3cce79a36bcb9b52d31df9df067d 100644 (file)
@@ -702,13 +702,6 @@ static int i2s_hw_params(struct snd_pcm_substream *substream,
        }
        writel(mod, i2s->addr + I2SMOD);
 
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               snd_soc_dai_set_dma_data(dai, substream,
-                       (void *)&i2s->dma_playback);
-       else
-               snd_soc_dai_set_dma_data(dai, substream,
-                       (void *)&i2s->dma_capture);
-
        i2s->frmclk = params_rate(params);
 
        return 0;
@@ -970,6 +963,8 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
        }
        clk_prepare_enable(i2s->clk);
 
+       snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
+
        if (other) {
                other->addr = i2s->addr;
                other->clk = i2s->clk;
@@ -1060,7 +1055,7 @@ static struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec)
        i2s->i2s_dai_drv.ops = &samsung_i2s_dai_ops;
        i2s->i2s_dai_drv.suspend = i2s_suspend;
        i2s->i2s_dai_drv.resume = i2s_resume;
-       i2s->i2s_dai_drv.playback.channels_min = 2;
+       i2s->i2s_dai_drv.playback.channels_min = 1;
        i2s->i2s_dai_drv.playback.channels_max = 2;
        i2s->i2s_dai_drv.playback.rates = SAMSUNG_I2S_RATES;
        i2s->i2s_dai_drv.playback.formats = SAMSUNG_I2S_FMTS;
@@ -1143,9 +1138,9 @@ static int samsung_i2s_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev, "Unable to get drvdata\n");
                        return -EFAULT;
                }
-               snd_soc_register_component(&sec_dai->pdev->dev,
-                                          &samsung_i2s_component,
-                                          &sec_dai->i2s_dai_drv, 1);
+               devm_snd_soc_register_component(&sec_dai->pdev->dev,
+                                               &samsung_i2s_component,
+                                               &sec_dai->i2s_dai_drv, 1);
                samsung_asoc_dma_platform_register(&pdev->dev);
                return 0;
        }
@@ -1258,8 +1253,9 @@ static int samsung_i2s_probe(struct platform_device *pdev)
                goto err;
        }
 
-       snd_soc_register_component(&pri_dai->pdev->dev, &samsung_i2s_component,
-                                  &pri_dai->i2s_dai_drv, 1);
+       devm_snd_soc_register_component(&pri_dai->pdev->dev,
+                                       &samsung_i2s_component,
+                                       &pri_dai->i2s_dai_drv, 1);
 
        pm_runtime_enable(&pdev->dev);
 
@@ -1294,7 +1290,6 @@ static int samsung_i2s_remove(struct platform_device *pdev)
        i2s->sec_dai = NULL;
 
        samsung_asoc_dma_platform_unregister(&pdev->dev);
-       snd_soc_unregister_component(&pdev->dev);
 
        return 0;
 }
index 5fd7a05a9b9e2fe9730a962bcdca73482a9e5d71..b072bd107b3150f8ca7e013e5190bfc285d78c4e 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "../codecs/wm8994.h"
 #include <sound/pcm_params.h>
+#include <sound/soc.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -193,7 +194,7 @@ static int smdk_audio_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, board);
 
-       ret = snd_soc_register_card(card);
+       ret = devm_snd_soc_register_card(&pdev->dev, card);
 
        if (ret)
                dev_err(&pdev->dev, "snd_soc_register_card() failed:%d\n", ret);
@@ -201,23 +202,14 @@ static int smdk_audio_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int smdk_audio_remove(struct platform_device *pdev)
-{
-       struct snd_soc_card *card = platform_get_drvdata(pdev);
-
-       snd_soc_unregister_card(card);
-
-       return 0;
-}
-
 static struct platform_driver smdk_audio_driver = {
        .driver         = {
                .name   = "smdk-audio-wm8894",
                .owner  = THIS_MODULE,
                .of_match_table = of_match_ptr(samsung_wm8994_of_match),
+               .pm     = &snd_soc_pm_ops,
        },
        .probe          = smdk_audio_probe,
-       .remove         = smdk_audio_remove,
 };
 
 module_platform_driver(smdk_audio_driver);
index d80deb7ccf13f7395ef79d78b2e51704a2844e4b..9430097979a580c972a989738bdeb9ada3557e5e 100644 (file)
@@ -8,7 +8,6 @@
  * for more details.
  */
 #include <linux/sh_clk.h>
-#include <mach/clock.h>
 #include "rsnd.h"
 
 #define CLKA   0
@@ -22,6 +21,7 @@ struct rsnd_adg {
 
        int rate_of_441khz_div_6;
        int rate_of_48khz_div_6;
+       u32 ckr;
 };
 
 #define for_each_rsnd_clk(pos, adg, i)         \
@@ -116,6 +116,11 @@ int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate)
 
 found_clock:
 
+       /* see rsnd_adg_ssi_clk_init() */
+       rsnd_mod_bset(mod, SSICKR, 0x00FF0000, adg->ckr);
+       rsnd_mod_write(mod, BRRA,  0x00000002); /* 1/6 */
+       rsnd_mod_write(mod, BRRB,  0x00000002); /* 1/6 */
+
        /*
         * This "mod" = "ssi" here.
         * we can get "ssi id" from mod
@@ -182,9 +187,7 @@ static void rsnd_adg_ssi_clk_init(struct rsnd_priv *priv, struct rsnd_adg *adg)
                }
        }
 
-       rsnd_priv_bset(priv, SSICKR, 0x00FF0000, ckr);
-       rsnd_priv_write(priv, BRRA,  0x00000002); /* 1/6 */
-       rsnd_priv_write(priv, BRRB,  0x00000002); /* 1/6 */
+       adg->ckr = ckr;
 }
 
 int rsnd_adg_probe(struct platform_device *pdev,
index a35706028514056e162afa491504d3864c6fa5c7..b234ed663073e76068830d56a806567856e4f62d 100644 (file)
  *     rsnd_platform functions
  */
 #define rsnd_platform_call(priv, dai, func, param...)  \
-       (!(priv->info->func) ? -ENODEV :                \
+       (!(priv->info->func) ? 0 :              \
         priv->info->func(param))
 
-
-/*
- *     basic function
- */
-u32 rsnd_read(struct rsnd_priv *priv,
-             struct rsnd_mod *mod, enum rsnd_reg reg)
-{
-       void __iomem *base = rsnd_gen_reg_get(priv, mod, reg);
-
-       BUG_ON(!base);
-
-       return ioread32(base);
-}
-
-void rsnd_write(struct rsnd_priv *priv,
-               struct rsnd_mod *mod,
-               enum rsnd_reg reg, u32 data)
-{
-       void __iomem *base = rsnd_gen_reg_get(priv, mod, reg);
-       struct device *dev = rsnd_priv_to_dev(priv);
-
-       BUG_ON(!base);
-
-       dev_dbg(dev, "w %p : %08x\n", base, data);
-
-       iowrite32(data, base);
-}
-
-void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod,
-              enum rsnd_reg reg, u32 mask, u32 data)
-{
-       void __iomem *base = rsnd_gen_reg_get(priv, mod, reg);
-       struct device *dev = rsnd_priv_to_dev(priv);
-       u32 val;
-
-       BUG_ON(!base);
-
-       val = ioread32(base);
-       val &= ~mask;
-       val |= data & mask;
-       iowrite32(val, base);
-
-       dev_dbg(dev, "s %p : %08x\n", base, val);
-}
-
 /*
  *     rsnd_mod functions
  */
@@ -363,6 +318,9 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai)
 
 struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id)
 {
+       if ((id < 0) || (id >= rsnd_dai_nr(priv)))
+               return NULL;
+
        return priv->rdai + id;
 }
 
index babb203b43b7bca938451d23fa3a5db99b542409..61212ee97c28269a0cd245e424636c4f38efc4c7 100644 (file)
 #include "rsnd.h"
 
 struct rsnd_gen_ops {
+       int (*probe)(struct platform_device *pdev,
+                    struct rcar_snd_info *info,
+                    struct rsnd_priv *priv);
+       void (*remove)(struct platform_device *pdev,
+                     struct rsnd_priv *priv);
        int (*path_init)(struct rsnd_priv *priv,
                         struct rsnd_dai *rdai,
                         struct rsnd_dai_stream *io);
@@ -19,21 +24,97 @@ struct rsnd_gen_ops {
                         struct rsnd_dai_stream *io);
 };
 
-struct rsnd_gen_reg_map {
-       int index;      /* -1 : not supported */
-       u32 offset_id;  /* offset of ssi0, ssi1, ssi2... */
-       u32 offset_adr; /* offset of SSICR, SSISR, ... */
-};
-
 struct rsnd_gen {
        void __iomem *base[RSND_BASE_MAX];
 
-       struct rsnd_gen_reg_map reg_map[RSND_REG_MAX];
        struct rsnd_gen_ops *ops;
+
+       struct regmap *regmap;
+       struct regmap_field *regs[RSND_REG_MAX];
 };
 
 #define rsnd_priv_to_gen(p)    ((struct rsnd_gen *)(p)->gen)
 
+#define RSND_REG_SET(gen, id, reg_id, offset, _id_offset, _id_size)    \
+       [id] = {                                                        \
+               .reg = (unsigned int)gen->base[reg_id] + offset,        \
+               .lsb = 0,                                               \
+               .msb = 31,                                              \
+               .id_size = _id_size,                                    \
+               .id_offset = _id_offset,                                \
+       }
+
+/*
+ *             basic function
+ */
+static int rsnd_regmap_write32(void *context, const void *_data, size_t count)
+{
+       struct rsnd_priv *priv = context;
+       struct device *dev = rsnd_priv_to_dev(priv);
+       u32 *data = (u32 *)_data;
+       u32 val = data[1];
+       void __iomem *reg = (void *)data[0];
+
+       iowrite32(val, reg);
+
+       dev_dbg(dev, "w %p : %08x\n", reg, val);
+
+       return 0;
+}
+
+static int rsnd_regmap_read32(void *context,
+                             const void *_data, size_t reg_size,
+                             void *_val, size_t val_size)
+{
+       struct rsnd_priv *priv = context;
+       struct device *dev = rsnd_priv_to_dev(priv);
+       u32 *data = (u32 *)_data;
+       u32 *val = (u32 *)_val;
+       void __iomem *reg = (void *)data[0];
+
+       *val = ioread32(reg);
+
+       dev_dbg(dev, "r %p : %08x\n", reg, *val);
+
+       return 0;
+}
+
+static struct regmap_bus rsnd_regmap_bus = {
+       .write                          = rsnd_regmap_write32,
+       .read                           = rsnd_regmap_read32,
+       .reg_format_endian_default      = REGMAP_ENDIAN_NATIVE,
+       .val_format_endian_default      = REGMAP_ENDIAN_NATIVE,
+};
+
+u32 rsnd_read(struct rsnd_priv *priv,
+             struct rsnd_mod *mod, enum rsnd_reg reg)
+{
+       struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
+       u32 val;
+
+       regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val);
+
+       return val;
+}
+
+void rsnd_write(struct rsnd_priv *priv,
+               struct rsnd_mod *mod,
+               enum rsnd_reg reg, u32 data)
+{
+       struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
+
+       regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data);
+}
+
+void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod,
+              enum rsnd_reg reg, u32 mask, u32 data)
+{
+       struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
+
+       regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod),
+                                 mask, data);
+}
+
 /*
  *             Gen2
  *             will be filled in the future
@@ -98,44 +179,64 @@ static int rsnd_gen1_path_exit(struct rsnd_priv *priv,
        return ret;
 }
 
-static struct rsnd_gen_ops rsnd_gen1_ops = {
-       .path_init      = rsnd_gen1_path_init,
-       .path_exit      = rsnd_gen1_path_exit,
-};
+/* single address mapping */
+#define RSND_GEN1_S_REG(gen, reg, id, offset)  \
+       RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9)
 
-#define RSND_GEN1_REG_MAP(g, s, i, oi, oa)                             \
-       do {                                                            \
-               (g)->reg_map[RSND_REG_##i].index  = RSND_GEN1_##s;      \
-               (g)->reg_map[RSND_REG_##i].offset_id = oi;              \
-               (g)->reg_map[RSND_REG_##i].offset_adr = oa;             \
-       } while (0)
+/* multi address mapping */
+#define RSND_GEN1_M_REG(gen, reg, id, offset, _id_offset)      \
+       RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, _id_offset, 9)
 
-static void rsnd_gen1_reg_map_init(struct rsnd_gen *gen)
+static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen)
 {
-       RSND_GEN1_REG_MAP(gen, SRU,     SRC_ROUTE_SEL,  0x0,    0x00);
-       RSND_GEN1_REG_MAP(gen, SRU,     SRC_TMG_SEL0,   0x0,    0x08);
-       RSND_GEN1_REG_MAP(gen, SRU,     SRC_TMG_SEL1,   0x0,    0x0c);
-       RSND_GEN1_REG_MAP(gen, SRU,     SRC_TMG_SEL2,   0x0,    0x10);
-       RSND_GEN1_REG_MAP(gen, SRU,     SRC_CTRL,       0x0,    0xc0);
-       RSND_GEN1_REG_MAP(gen, SRU,     SSI_MODE0,      0x0,    0xD0);
-       RSND_GEN1_REG_MAP(gen, SRU,     SSI_MODE1,      0x0,    0xD4);
-       RSND_GEN1_REG_MAP(gen, SRU,     BUSIF_MODE,     0x4,    0x20);
-       RSND_GEN1_REG_MAP(gen, SRU,     BUSIF_ADINR,    0x40,   0x214);
-
-       RSND_GEN1_REG_MAP(gen, ADG,     BRRA,           0x0,    0x00);
-       RSND_GEN1_REG_MAP(gen, ADG,     BRRB,           0x0,    0x04);
-       RSND_GEN1_REG_MAP(gen, ADG,     SSICKR,         0x0,    0x08);
-       RSND_GEN1_REG_MAP(gen, ADG,     AUDIO_CLK_SEL0, 0x0,    0x0c);
-       RSND_GEN1_REG_MAP(gen, ADG,     AUDIO_CLK_SEL1, 0x0,    0x10);
-       RSND_GEN1_REG_MAP(gen, ADG,     AUDIO_CLK_SEL3, 0x0,    0x18);
-       RSND_GEN1_REG_MAP(gen, ADG,     AUDIO_CLK_SEL4, 0x0,    0x1c);
-       RSND_GEN1_REG_MAP(gen, ADG,     AUDIO_CLK_SEL5, 0x0,    0x20);
-
-       RSND_GEN1_REG_MAP(gen, SSI,     SSICR,          0x40,   0x00);
-       RSND_GEN1_REG_MAP(gen, SSI,     SSISR,          0x40,   0x04);
-       RSND_GEN1_REG_MAP(gen, SSI,     SSITDR,         0x40,   0x08);
-       RSND_GEN1_REG_MAP(gen, SSI,     SSIRDR,         0x40,   0x0c);
-       RSND_GEN1_REG_MAP(gen, SSI,     SSIWSR,         0x40,   0x20);
+       int i;
+       struct device *dev = rsnd_priv_to_dev(priv);
+       struct regmap_config regc;
+       struct reg_field regf[RSND_REG_MAX] = {
+               RSND_GEN1_S_REG(gen, SRU,       SRC_ROUTE_SEL,  0x00),
+               RSND_GEN1_S_REG(gen, SRU,       SRC_TMG_SEL0,   0x08),
+               RSND_GEN1_S_REG(gen, SRU,       SRC_TMG_SEL1,   0x0c),
+               RSND_GEN1_S_REG(gen, SRU,       SRC_TMG_SEL2,   0x10),
+               RSND_GEN1_S_REG(gen, SRU,       SRC_CTRL,       0xc0),
+               RSND_GEN1_S_REG(gen, SRU,       SSI_MODE0,      0xD0),
+               RSND_GEN1_S_REG(gen, SRU,       SSI_MODE1,      0xD4),
+               RSND_GEN1_M_REG(gen, SRU,       BUSIF_MODE,     0x20,   0x4),
+               RSND_GEN1_M_REG(gen, SRU,       BUSIF_ADINR,    0x214,  0x40),
+
+               RSND_GEN1_S_REG(gen, ADG,       BRRA,           0x00),
+               RSND_GEN1_S_REG(gen, ADG,       BRRB,           0x04),
+               RSND_GEN1_S_REG(gen, ADG,       SSICKR,         0x08),
+               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL0, 0x0c),
+               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL1, 0x10),
+               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL3, 0x18),
+               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL4, 0x1c),
+               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL5, 0x20),
+
+               RSND_GEN1_M_REG(gen, SSI,       SSICR,          0x00,   0x40),
+               RSND_GEN1_M_REG(gen, SSI,       SSISR,          0x04,   0x40),
+               RSND_GEN1_M_REG(gen, SSI,       SSITDR,         0x08,   0x40),
+               RSND_GEN1_M_REG(gen, SSI,       SSIRDR,         0x0c,   0x40),
+               RSND_GEN1_M_REG(gen, SSI,       SSIWSR,         0x20,   0x40),
+       };
+
+       memset(&regc, 0, sizeof(regc));
+       regc.reg_bits = 32;
+       regc.val_bits = 32;
+
+       gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, &regc);
+       if (IS_ERR(gen->regmap)) {
+               dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap));
+               return PTR_ERR(gen->regmap);
+       }
+
+       for (i = 0; i < RSND_REG_MAX; i++) {
+               gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]);
+               if (IS_ERR(gen->regs[i]))
+                       return PTR_ERR(gen->regs[i]);
+
+       }
+
+       return 0;
 }
 
 static int rsnd_gen1_probe(struct platform_device *pdev,
@@ -147,6 +248,7 @@ static int rsnd_gen1_probe(struct platform_device *pdev,
        struct resource *sru_res;
        struct resource *adg_res;
        struct resource *ssi_res;
+       int ret;
 
        /*
         * map address
@@ -163,8 +265,9 @@ static int rsnd_gen1_probe(struct platform_device *pdev,
            IS_ERR(gen->base[RSND_GEN1_SSI]))
                return -ENODEV;
 
-       gen->ops = &rsnd_gen1_ops;
-       rsnd_gen1_reg_map_init(gen);
+       ret = rsnd_gen1_regmap_init(priv, gen);
+       if (ret < 0)
+               return ret;
 
        dev_dbg(dev, "Gen1 device probed\n");
        dev_dbg(dev, "SRU : %08x => %p\n",      sru_res->start,
@@ -183,6 +286,13 @@ static void rsnd_gen1_remove(struct platform_device *pdev,
 {
 }
 
+static struct rsnd_gen_ops rsnd_gen1_ops = {
+       .probe          = rsnd_gen1_probe,
+       .remove         = rsnd_gen1_remove,
+       .path_init      = rsnd_gen1_path_init,
+       .path_exit      = rsnd_gen1_path_exit,
+};
+
 /*
  *             Gen
  */
@@ -204,46 +314,12 @@ int rsnd_gen_path_exit(struct rsnd_priv *priv,
        return gen->ops->path_exit(priv, rdai, io);
 }
 
-void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
-                              struct rsnd_mod *mod,
-                              enum rsnd_reg reg)
-{
-       struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
-       struct device *dev = rsnd_priv_to_dev(priv);
-       int index;
-       u32 offset_id, offset_adr;
-
-       if (reg >= RSND_REG_MAX) {
-               dev_err(dev, "rsnd_reg reg error\n");
-               return NULL;
-       }
-
-       index           = gen->reg_map[reg].index;
-       offset_id       = gen->reg_map[reg].offset_id;
-       offset_adr      = gen->reg_map[reg].offset_adr;
-
-       if (index < 0) {
-               dev_err(dev, "unsupported reg access %d\n", reg);
-               return NULL;
-       }
-
-       if (offset_id && mod)
-               offset_id *= rsnd_mod_id(mod);
-
-       /*
-        * index/offset were set on gen1/gen2
-        */
-
-       return gen->base[index] + offset_id + offset_adr;
-}
-
 int rsnd_gen_probe(struct platform_device *pdev,
                   struct rcar_snd_info *info,
                   struct rsnd_priv *priv)
 {
        struct device *dev = rsnd_priv_to_dev(priv);
        struct rsnd_gen *gen;
-       int i;
 
        gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL);
        if (!gen) {
@@ -251,30 +327,23 @@ int rsnd_gen_probe(struct platform_device *pdev,
                return -ENOMEM;
        }
 
-       priv->gen = gen;
-
-       /*
-        * see
-        *      rsnd_reg_get()
-        *      rsnd_gen_probe()
-        */
-       for (i = 0; i < RSND_REG_MAX; i++)
-               gen->reg_map[i].index = -1;
-
-       /*
-        *      init each module
-        */
        if (rsnd_is_gen1(priv))
-               return rsnd_gen1_probe(pdev, info, priv);
+               gen->ops = &rsnd_gen1_ops;
 
-       dev_err(dev, "unknown generation R-Car sound device\n");
+       if (!gen->ops) {
+               dev_err(dev, "unknown generation R-Car sound device\n");
+               return -ENODEV;
+       }
 
-       return -ENODEV;
+       priv->gen = gen;
+
+       return gen->ops->probe(pdev, info, priv);
 }
 
 void rsnd_gen_remove(struct platform_device *pdev,
                     struct rsnd_priv *priv)
 {
-       if (rsnd_is_gen1(priv))
-               rsnd_gen1_remove(pdev, priv);
+       struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
+
+       gen->ops->remove(pdev, priv);
 }
index 5dd87f4c919e50650e61e8084856138d47f6f119..9e463e50e7e62b81fabeaeecf39f50de4206eeaf 100644 (file)
@@ -78,10 +78,6 @@ struct rsnd_dai_stream;
 #define rsnd_mod_bset(m, r, s, d) \
        rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d)
 
-#define rsnd_priv_read(p, r)           rsnd_read(p, NULL, RSND_REG_##r)
-#define rsnd_priv_write(p, r, d)       rsnd_write(p, NULL, RSND_REG_##r, d)
-#define rsnd_priv_bset(p, r, s, d)     rsnd_bset(p, NULL, RSND_REG_##r, s, d)
-
 u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg);
 void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
                enum rsnd_reg reg, u32 data);
@@ -285,6 +281,7 @@ int rsnd_scu_probe(struct platform_device *pdev,
 void rsnd_scu_remove(struct platform_device *pdev,
                     struct rsnd_priv *priv);
 struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id);
+bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod);
 #define rsnd_scu_nr(priv) ((priv)->scu_nr)
 
 /*
index 2df2e9150b893498ffbc15991b1a47e2f9dfd47a..1ab1bce6be7f644affa15b4855b3f2f398d125d9 100644 (file)
@@ -146,20 +146,26 @@ static int rsnd_scu_set_hpbif(struct rsnd_priv *priv,
        return 0;
 }
 
+bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod)
+{
+       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
+       u32 flags = rsnd_scu_mode_flags(scu);
+
+       return !!(flags & RSND_SCU_USE_HPBIF);
+}
+
 static int rsnd_scu_start(struct rsnd_mod *mod,
                          struct rsnd_dai *rdai,
                          struct rsnd_dai_stream *io)
 {
        struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
-       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
        struct device *dev = rsnd_priv_to_dev(priv);
-       u32 flags = rsnd_scu_mode_flags(scu);
        int ret;
 
        /*
         * SCU will be used if it has RSND_SCU_USE_HPBIF flags
         */
-       if (!(flags & RSND_SCU_USE_HPBIF)) {
+       if (!rsnd_scu_hpbif_is_enable(mod)) {
                /* it use PIO transter */
                dev_dbg(dev, "%s%d is not used\n",
                        rsnd_mod_name(mod), rsnd_mod_id(mod));
index fae26d3f79d26bf827cc931bd16fe186800f777d..b71cf9d7dd3febe600465b40cdc5dcaaedb5b6fb 100644 (file)
@@ -101,29 +101,30 @@ struct rsnd_ssiu {
 #define rsnd_ssi_to_ssiu(ssi)\
        (((struct rsnd_ssiu *)((ssi) - rsnd_mod_id(&(ssi)->mod))) - 1)
 
-static void rsnd_ssi_mode_init(struct rsnd_priv *priv,
-                              struct rsnd_ssiu *ssiu)
+static void rsnd_ssi_mode_set(struct rsnd_priv *priv,
+                             struct rsnd_dai *rdai,
+                             struct rsnd_ssi *ssi)
 {
        struct device *dev = rsnd_priv_to_dev(priv);
-       struct rsnd_ssi *ssi;
+       struct rsnd_mod *scu;
+       struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi);
+       int id = rsnd_mod_id(&ssi->mod);
        u32 flags;
        u32 val;
-       int i;
+
+       scu   = rsnd_scu_mod_get(priv, rsnd_mod_id(&ssi->mod));
 
        /*
         * SSI_MODE0
         */
-       ssiu->ssi_mode0 = 0;
-       for_each_rsnd_ssi(ssi, priv, i) {
-               flags = rsnd_ssi_mode_flags(ssi);
-
-               /* see also BUSIF_MODE */
-               if (!(flags & RSND_SSI_DEPENDENT)) {
-                       ssiu->ssi_mode0 |= (1 << i);
-                       dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", i);
-               } else {
-                       dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", i);
-               }
+
+       /* see also BUSIF_MODE */
+       if (rsnd_scu_hpbif_is_enable(scu)) {
+               ssiu->ssi_mode0 &= ~(1 << id);
+               dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", id);
+       } else {
+               ssiu->ssi_mode0 |= (1 << id);
+               dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", id);
        }
 
        /*
@@ -132,7 +133,7 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv,
 #define ssi_parent_set(p, sync, adg, ext)              \
        do {                                            \
                ssi->parent = ssiu->ssi + p;            \
-               if (flags & RSND_SSI_CLK_FROM_ADG)      \
+               if (rsnd_rdai_is_clk_master(rdai))      \
                        val = adg;                      \
                else                                    \
                        val = ext;                      \
@@ -140,15 +141,11 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv,
                        val |= sync;                    \
        } while (0)
 
-       ssiu->ssi_mode1 = 0;
-       for_each_rsnd_ssi(ssi, priv, i) {
-               flags = rsnd_ssi_mode_flags(ssi);
-
-               if (!(flags & RSND_SSI_CLK_PIN_SHARE))
-                       continue;
+       flags = rsnd_ssi_mode_flags(ssi);
+       if (flags & RSND_SSI_CLK_PIN_SHARE) {
 
                val = 0;
-               switch (i) {
+               switch (id) {
                case 1:
                        ssi_parent_set(0, (1 << 4), (0x2 << 0), (0x1 << 0));
                        break;
@@ -165,11 +162,6 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv,
 
                ssiu->ssi_mode1 |= val;
        }
-}
-
-static void rsnd_ssi_mode_set(struct rsnd_ssi *ssi)
-{
-       struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi);
 
        rsnd_mod_write(&ssi->mod, SSI_MODE0, ssiu->ssi_mode0);
        rsnd_mod_write(&ssi->mod, SSI_MODE1, ssiu->ssi_mode1);
@@ -379,7 +371,7 @@ static int rsnd_ssi_init(struct rsnd_mod *mod,
        ssi->cr_own     = cr;
        ssi->err        = -1; /* ignore 1st error */
 
-       rsnd_ssi_mode_set(ssi);
+       rsnd_ssi_mode_set(priv, rdai, ssi);
 
        dev_dbg(dev, "%s.%d init\n", rsnd_mod_name(mod), rsnd_mod_id(mod));
 
@@ -706,8 +698,6 @@ int rsnd_ssi_probe(struct platform_device *pdev,
                rsnd_mod_init(priv, &ssi->mod, ops, i);
        }
 
-       rsnd_ssi_mode_init(priv, ssiu);
-
        dev_dbg(dev, "ssi probed\n");
 
        return 0;
index e72f55428f0ba8ece44cdea8f6f720efc5c1d868..1b6663f45b3435c40fe751491c2c228121c62e00 100644 (file)
  *  option) any later version.
  */
 
-#include <linux/i2c.h>
-#include <linux/spi/spi.h>
 #include <sound/soc.h>
-#include <linux/bitmap.h>
-#include <linux/rbtree.h>
 #include <linux/export.h>
+#include <linux/slab.h>
 
 #include <trace/events/asoc.h>
 
@@ -66,126 +63,42 @@ static unsigned int snd_soc_get_cache_val(const void *base, unsigned int idx,
        return -1;
 }
 
-static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec)
+int snd_soc_cache_init(struct snd_soc_codec *codec)
 {
-       int i;
-       int ret;
-       const struct snd_soc_codec_driver *codec_drv;
-       unsigned int val;
+       const struct snd_soc_codec_driver *codec_drv = codec->driver;
+       size_t reg_size;
 
-       codec_drv = codec->driver;
-       for (i = 0; i < codec_drv->reg_cache_size; ++i) {
-               ret = snd_soc_cache_read(codec, i, &val);
-               if (ret)
-                       return ret;
-               if (codec->reg_def_copy)
-                       if (snd_soc_get_cache_val(codec->reg_def_copy,
-                                                 i, codec_drv->reg_word_size) == val)
-                               continue;
+       reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
 
-               WARN_ON(!snd_soc_codec_writable_register(codec, i));
-
-               ret = snd_soc_write(codec, i, val);
-               if (ret)
-                       return ret;
-               dev_dbg(codec->dev, "ASoC: Synced register %#x, value = %#x\n",
-                       i, val);
-       }
-       return 0;
-}
-
-static int snd_soc_flat_cache_write(struct snd_soc_codec *codec,
-                                   unsigned int reg, unsigned int value)
-{
-       snd_soc_set_cache_val(codec->reg_cache, reg, value,
-                             codec->driver->reg_word_size);
-       return 0;
-}
-
-static int snd_soc_flat_cache_read(struct snd_soc_codec *codec,
-                                  unsigned int reg, unsigned int *value)
-{
-       *value = snd_soc_get_cache_val(codec->reg_cache, reg,
-                                      codec->driver->reg_word_size);
-       return 0;
-}
+       mutex_init(&codec->cache_rw_mutex);
 
-static int snd_soc_flat_cache_exit(struct snd_soc_codec *codec)
-{
-       if (!codec->reg_cache)
-               return 0;
-       kfree(codec->reg_cache);
-       codec->reg_cache = NULL;
-       return 0;
-}
+       dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n",
+                               codec->name);
 
-static int snd_soc_flat_cache_init(struct snd_soc_codec *codec)
-{
-       if (codec->reg_def_copy)
-               codec->reg_cache = kmemdup(codec->reg_def_copy,
-                                          codec->reg_size, GFP_KERNEL);
+       if (codec_drv->reg_cache_default)
+               codec->reg_cache = kmemdup(codec_drv->reg_cache_default,
+                                          reg_size, GFP_KERNEL);
        else
-               codec->reg_cache = kzalloc(codec->reg_size, GFP_KERNEL);
+               codec->reg_cache = kzalloc(reg_size, GFP_KERNEL);
        if (!codec->reg_cache)
                return -ENOMEM;
 
        return 0;
 }
 
-/* an array of all supported compression types */
-static const struct snd_soc_cache_ops cache_types[] = {
-       /* Flat *must* be the first entry for fallback */
-       {
-               .id = SND_SOC_FLAT_COMPRESSION,
-               .name = "flat",
-               .init = snd_soc_flat_cache_init,
-               .exit = snd_soc_flat_cache_exit,
-               .read = snd_soc_flat_cache_read,
-               .write = snd_soc_flat_cache_write,
-               .sync = snd_soc_flat_cache_sync
-       },
-};
-
-int snd_soc_cache_init(struct snd_soc_codec *codec)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(cache_types); ++i)
-               if (cache_types[i].id == codec->compress_type)
-                       break;
-
-       /* Fall back to flat compression */
-       if (i == ARRAY_SIZE(cache_types)) {
-               dev_warn(codec->dev, "ASoC: Could not match compress type: %d\n",
-                        codec->compress_type);
-               i = 0;
-       }
-
-       mutex_init(&codec->cache_rw_mutex);
-       codec->cache_ops = &cache_types[i];
-
-       if (codec->cache_ops->init) {
-               if (codec->cache_ops->name)
-                       dev_dbg(codec->dev, "ASoC: Initializing %s cache for %s codec\n",
-                               codec->cache_ops->name, codec->name);
-               return codec->cache_ops->init(codec);
-       }
-       return -ENOSYS;
-}
-
 /*
  * NOTE: keep in mind that this function might be called
  * multiple times.
  */
 int snd_soc_cache_exit(struct snd_soc_codec *codec)
 {
-       if (codec->cache_ops && codec->cache_ops->exit) {
-               if (codec->cache_ops->name)
-                       dev_dbg(codec->dev, "ASoC: Destroying %s cache for %s codec\n",
-                               codec->cache_ops->name, codec->name);
-               return codec->cache_ops->exit(codec);
-       }
-       return -ENOSYS;
+       dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n",
+                       codec->name);
+       if (!codec->reg_cache)
+               return 0;
+       kfree(codec->reg_cache);
+       codec->reg_cache = NULL;
+       return 0;
 }
 
 /**
@@ -198,18 +111,15 @@ int snd_soc_cache_exit(struct snd_soc_codec *codec)
 int snd_soc_cache_read(struct snd_soc_codec *codec,
                       unsigned int reg, unsigned int *value)
 {
-       int ret;
+       if (!value)
+               return -EINVAL;
 
        mutex_lock(&codec->cache_rw_mutex);
-
-       if (value && codec->cache_ops && codec->cache_ops->read) {
-               ret = codec->cache_ops->read(codec, reg, value);
-               mutex_unlock(&codec->cache_rw_mutex);
-               return ret;
-       }
-
+       *value = snd_soc_get_cache_val(codec->reg_cache, reg,
+                                      codec->driver->reg_word_size);
        mutex_unlock(&codec->cache_rw_mutex);
-       return -ENOSYS;
+
+       return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_cache_read);
 
@@ -223,20 +133,42 @@ EXPORT_SYMBOL_GPL(snd_soc_cache_read);
 int snd_soc_cache_write(struct snd_soc_codec *codec,
                        unsigned int reg, unsigned int value)
 {
+       mutex_lock(&codec->cache_rw_mutex);
+       snd_soc_set_cache_val(codec->reg_cache, reg, value,
+                             codec->driver->reg_word_size);
+       mutex_unlock(&codec->cache_rw_mutex);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_cache_write);
+
+static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec)
+{
+       int i;
        int ret;
+       const struct snd_soc_codec_driver *codec_drv;
+       unsigned int val;
 
-       mutex_lock(&codec->cache_rw_mutex);
+       codec_drv = codec->driver;
+       for (i = 0; i < codec_drv->reg_cache_size; ++i) {
+               ret = snd_soc_cache_read(codec, i, &val);
+               if (ret)
+                       return ret;
+               if (codec_drv->reg_cache_default)
+                       if (snd_soc_get_cache_val(codec_drv->reg_cache_default,
+                                                 i, codec_drv->reg_word_size) == val)
+                               continue;
 
-       if (codec->cache_ops && codec->cache_ops->write) {
-               ret = codec->cache_ops->write(codec, reg, value);
-               mutex_unlock(&codec->cache_rw_mutex);
-               return ret;
-       }
+               WARN_ON(!snd_soc_codec_writable_register(codec, i));
 
-       mutex_unlock(&codec->cache_rw_mutex);
-       return -ENOSYS;
+               ret = snd_soc_write(codec, i, val);
+               if (ret)
+                       return ret;
+               dev_dbg(codec->dev, "ASoC: Synced register %#x, value = %#x\n",
+                       i, val);
+       }
+       return 0;
 }
-EXPORT_SYMBOL_GPL(snd_soc_cache_write);
 
 /**
  * snd_soc_cache_sync: Sync the register cache with the hardware.
@@ -249,92 +181,19 @@ EXPORT_SYMBOL_GPL(snd_soc_cache_write);
  */
 int snd_soc_cache_sync(struct snd_soc_codec *codec)
 {
+       const char *name = "flat";
        int ret;
-       const char *name;
 
-       if (!codec->cache_sync) {
+       if (!codec->cache_sync)
                return 0;
-       }
-
-       if (!codec->cache_ops || !codec->cache_ops->sync)
-               return -ENOSYS;
 
-       if (codec->cache_ops->name)
-               name = codec->cache_ops->name;
-       else
-               name = "unknown";
-
-       if (codec->cache_ops->name)
-               dev_dbg(codec->dev, "ASoC: Syncing %s cache for %s codec\n",
-                       codec->cache_ops->name, codec->name);
+       dev_dbg(codec->dev, "ASoC: Syncing cache for %s codec\n",
+               codec->name);
        trace_snd_soc_cache_sync(codec, name, "start");
-       ret = codec->cache_ops->sync(codec);
+       ret = snd_soc_flat_cache_sync(codec);
        if (!ret)
                codec->cache_sync = 0;
        trace_snd_soc_cache_sync(codec, name, "end");
        return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_cache_sync);
-
-static int snd_soc_get_reg_access_index(struct snd_soc_codec *codec,
-                                       unsigned int reg)
-{
-       const struct snd_soc_codec_driver *codec_drv;
-       unsigned int min, max, index;
-
-       codec_drv = codec->driver;
-       min = 0;
-       max = codec_drv->reg_access_size - 1;
-       do {
-               index = (min + max) / 2;
-               if (codec_drv->reg_access_default[index].reg == reg)
-                       return index;
-               if (codec_drv->reg_access_default[index].reg < reg)
-                       min = index + 1;
-               else
-                       max = index;
-       } while (min <= max);
-       return -1;
-}
-
-int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
-                                     unsigned int reg)
-{
-       int index;
-
-       if (reg >= codec->driver->reg_cache_size)
-               return 1;
-       index = snd_soc_get_reg_access_index(codec, reg);
-       if (index < 0)
-               return 0;
-       return codec->driver->reg_access_default[index].vol;
-}
-EXPORT_SYMBOL_GPL(snd_soc_default_volatile_register);
-
-int snd_soc_default_readable_register(struct snd_soc_codec *codec,
-                                     unsigned int reg)
-{
-       int index;
-
-       if (reg >= codec->driver->reg_cache_size)
-               return 1;
-       index = snd_soc_get_reg_access_index(codec, reg);
-       if (index < 0)
-               return 0;
-       return codec->driver->reg_access_default[index].read;
-}
-EXPORT_SYMBOL_GPL(snd_soc_default_readable_register);
-
-int snd_soc_default_writable_register(struct snd_soc_codec *codec,
-                                     unsigned int reg)
-{
-       int index;
-
-       if (reg >= codec->driver->reg_cache_size)
-               return 1;
-       index = snd_soc_get_reg_access_index(codec, reg);
-       if (index < 0)
-               return 0;
-       return codec->driver->reg_access_default[index].write;
-}
-EXPORT_SYMBOL_GPL(snd_soc_default_writable_register);
index 1a38be0d0ca8fbf0724bbec4087569ee418d39a2..afc3fa8b747091bcf4b4590d71c05b605bb82710 100644 (file)
@@ -1589,17 +1589,13 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
                soc_remove_codec(codec);
 }
 
-static int snd_soc_init_codec_cache(struct snd_soc_codec *codec,
-                                   enum snd_soc_compress_type compress_type)
+static int snd_soc_init_codec_cache(struct snd_soc_codec *codec)
 {
        int ret;
 
        if (codec->cache_init)
                return 0;
 
-       /* override the compress_type if necessary */
-       if (compress_type && codec->compress_type != compress_type)
-               codec->compress_type = compress_type;
        ret = snd_soc_cache_init(codec);
        if (ret < 0) {
                dev_err(codec->dev,
@@ -1614,8 +1610,6 @@ static int snd_soc_init_codec_cache(struct snd_soc_codec *codec,
 static int snd_soc_instantiate_card(struct snd_soc_card *card)
 {
        struct snd_soc_codec *codec;
-       struct snd_soc_codec_conf *codec_conf;
-       enum snd_soc_compress_type compress_type;
        struct snd_soc_dai_link *dai_link;
        int ret, i, order, dai_fmt;
 
@@ -1639,19 +1633,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
        list_for_each_entry(codec, &codec_list, list) {
                if (codec->cache_init)
                        continue;
-               /* by default we don't override the compress_type */
-               compress_type = 0;
-               /* check to see if we need to override the compress_type */
-               for (i = 0; i < card->num_configs; ++i) {
-                       codec_conf = &card->codec_conf[i];
-                       if (!strcmp(codec->name, codec_conf->dev_name)) {
-                               compress_type = codec_conf->compress_type;
-                               if (compress_type && compress_type
-                                   != codec->compress_type)
-                                       break;
-                       }
-               }
-               ret = snd_soc_init_codec_cache(codec, compress_type);
+               ret = snd_soc_init_codec_cache(codec);
                if (ret < 0)
                        goto base_error;
        }
@@ -2297,13 +2279,6 @@ unsigned int snd_soc_write(struct snd_soc_codec *codec,
 }
 EXPORT_SYMBOL_GPL(snd_soc_write);
 
-unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec,
-                                   unsigned int reg, const void *data, size_t len)
-{
-       return codec->bulk_write_raw(codec, reg, data, len);
-}
-EXPORT_SYMBOL_GPL(snd_soc_bulk_write_raw);
-
 /**
  * snd_soc_update_bits - update codec register bits
  * @codec: audio codec
@@ -3575,6 +3550,22 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
 }
 EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll);
 
+/**
+ * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio.
+ * @dai: DAI
+ * @ratio Ratio of BCLK to Sample rate.
+ *
+ * Configures the DAI for a preset BCLK to sample rate ratio.
+ */
+int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
+{
+       if (dai->driver && dai->driver->ops->set_bclk_ratio)
+               return dai->driver->ops->set_bclk_ratio(dai, ratio);
+       else
+               return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
+
 /**
  * snd_soc_dai_set_fmt - configure DAI hardware audio format.
  * @dai: DAI
@@ -4019,6 +4010,113 @@ static void snd_soc_unregister_dais(struct device *dev, size_t count)
                snd_soc_unregister_dai(dev);
 }
 
+/**
+ * snd_soc_register_component - Register a component with the ASoC core
+ *
+ */
+static int
+__snd_soc_register_component(struct device *dev,
+                            struct snd_soc_component *cmpnt,
+                            const struct snd_soc_component_driver *cmpnt_drv,
+                            struct snd_soc_dai_driver *dai_drv,
+                            int num_dai, bool allow_single_dai)
+{
+       int ret;
+
+       dev_dbg(dev, "component register %s\n", dev_name(dev));
+
+       if (!cmpnt) {
+               dev_err(dev, "ASoC: Failed to connecting component\n");
+               return -ENOMEM;
+       }
+
+       cmpnt->name = fmt_single_name(dev, &cmpnt->id);
+       if (!cmpnt->name) {
+               dev_err(dev, "ASoC: Failed to simplifying name\n");
+               return -ENOMEM;
+       }
+
+       cmpnt->dev      = dev;
+       cmpnt->driver   = cmpnt_drv;
+       cmpnt->dai_drv  = dai_drv;
+       cmpnt->num_dai  = num_dai;
+
+       /*
+        * snd_soc_register_dai()  uses fmt_single_name(), and
+        * snd_soc_register_dais() uses fmt_multiple_name()
+        * for dai->name which is used for name based matching
+        *
+        * this function is used from cpu/codec.
+        * allow_single_dai flag can ignore "codec" driver reworking
+        * since it had been used snd_soc_register_dais(),
+        */
+       if ((1 == num_dai) && allow_single_dai)
+               ret = snd_soc_register_dai(dev, dai_drv);
+       else
+               ret = snd_soc_register_dais(dev, dai_drv, num_dai);
+       if (ret < 0) {
+               dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret);
+               goto error_component_name;
+       }
+
+       mutex_lock(&client_mutex);
+       list_add(&cmpnt->list, &component_list);
+       mutex_unlock(&client_mutex);
+
+       dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name);
+
+       return ret;
+
+error_component_name:
+       kfree(cmpnt->name);
+
+       return ret;
+}
+
+int snd_soc_register_component(struct device *dev,
+                              const struct snd_soc_component_driver *cmpnt_drv,
+                              struct snd_soc_dai_driver *dai_drv,
+                              int num_dai)
+{
+       struct snd_soc_component *cmpnt;
+
+       cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL);
+       if (!cmpnt) {
+               dev_err(dev, "ASoC: Failed to allocate memory\n");
+               return -ENOMEM;
+       }
+
+       return __snd_soc_register_component(dev, cmpnt, cmpnt_drv,
+                                           dai_drv, num_dai, true);
+}
+EXPORT_SYMBOL_GPL(snd_soc_register_component);
+
+/**
+ * snd_soc_unregister_component - Unregister a component from the ASoC core
+ *
+ */
+void snd_soc_unregister_component(struct device *dev)
+{
+       struct snd_soc_component *cmpnt;
+
+       list_for_each_entry(cmpnt, &component_list, list) {
+               if (dev == cmpnt->dev)
+                       goto found;
+       }
+       return;
+
+found:
+       snd_soc_unregister_dais(dev, cmpnt->num_dai);
+
+       mutex_lock(&client_mutex);
+       list_del(&cmpnt->list);
+       mutex_unlock(&client_mutex);
+
+       dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name);
+       kfree(cmpnt->name);
+}
+EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
+
 /**
  * snd_soc_add_platform - Add a platform to the ASoC core
  * @dev: The parent device for the platform
@@ -4165,7 +4263,6 @@ int snd_soc_register_codec(struct device *dev,
                           struct snd_soc_dai_driver *dai_drv,
                           int num_dai)
 {
-       size_t reg_size;
        struct snd_soc_codec *codec;
        int ret, i;
 
@@ -4182,11 +4279,6 @@ int snd_soc_register_codec(struct device *dev,
                goto fail_codec;
        }
 
-       if (codec_drv->compress_type)
-               codec->compress_type = codec_drv->compress_type;
-       else
-               codec->compress_type = SND_SOC_FLAT_COMPRESSION;
-
        codec->write = codec_drv->write;
        codec->read = codec_drv->read;
        codec->volatile_register = codec_drv->volatile_register;
@@ -4203,35 +4295,6 @@ int snd_soc_register_codec(struct device *dev,
        codec->num_dai = num_dai;
        mutex_init(&codec->mutex);
 
-       /* allocate CODEC register cache */
-       if (codec_drv->reg_cache_size && codec_drv->reg_word_size) {
-               reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
-               codec->reg_size = reg_size;
-               /* it is necessary to make a copy of the default register cache
-                * because in the case of using a compression type that requires
-                * the default register cache to be marked as the
-                * kernel might have freed the array by the time we initialize
-                * the cache.
-                */
-               if (codec_drv->reg_cache_default) {
-                       codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
-                                                     reg_size, GFP_KERNEL);
-                       if (!codec->reg_def_copy) {
-                               ret = -ENOMEM;
-                               goto fail_codec_name;
-                       }
-               }
-       }
-
-       if (codec_drv->reg_access_size && codec_drv->reg_access_default) {
-               if (!codec->volatile_register)
-                       codec->volatile_register = snd_soc_default_volatile_register;
-               if (!codec->readable_register)
-                       codec->readable_register = snd_soc_default_readable_register;
-               if (!codec->writable_register)
-                       codec->writable_register = snd_soc_default_writable_register;
-       }
-
        for (i = 0; i < num_dai; i++) {
                fixup_codec_formats(&dai_drv[i].playback);
                fixup_codec_formats(&dai_drv[i].capture);
@@ -4241,10 +4304,12 @@ int snd_soc_register_codec(struct device *dev,
        list_add(&codec->list, &codec_list);
        mutex_unlock(&client_mutex);
 
-       /* register any DAIs */
-       ret = snd_soc_register_dais(dev, dai_drv, num_dai);
+       /* register component */
+       ret = __snd_soc_register_component(dev, &codec->component,
+                                          &codec_drv->component_driver,
+                                          dai_drv, num_dai, false);
        if (ret < 0) {
-               dev_err(codec->dev, "ASoC: Failed to regster DAIs: %d\n", ret);
+               dev_err(codec->dev, "ASoC: Failed to regster component: %d\n", ret);
                goto fail_codec_name;
        }
 
@@ -4279,7 +4344,7 @@ void snd_soc_unregister_codec(struct device *dev)
        return;
 
 found:
-       snd_soc_unregister_dais(dev, codec->num_dai);
+       snd_soc_unregister_component(dev);
 
        mutex_lock(&client_mutex);
        list_del(&codec->list);
@@ -4288,98 +4353,11 @@ found:
        dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name);
 
        snd_soc_cache_exit(codec);
-       kfree(codec->reg_def_copy);
        kfree(codec->name);
        kfree(codec);
 }
 EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
 
-
-/**
- * snd_soc_register_component - Register a component with the ASoC core
- *
- */
-int snd_soc_register_component(struct device *dev,
-                        const struct snd_soc_component_driver *cmpnt_drv,
-                        struct snd_soc_dai_driver *dai_drv,
-                        int num_dai)
-{
-       struct snd_soc_component *cmpnt;
-       int ret;
-
-       dev_dbg(dev, "component register %s\n", dev_name(dev));
-
-       cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL);
-       if (!cmpnt) {
-               dev_err(dev, "ASoC: Failed to allocate memory\n");
-               return -ENOMEM;
-       }
-
-       cmpnt->name = fmt_single_name(dev, &cmpnt->id);
-       if (!cmpnt->name) {
-               dev_err(dev, "ASoC: Failed to simplifying name\n");
-               return -ENOMEM;
-       }
-
-       cmpnt->dev      = dev;
-       cmpnt->driver   = cmpnt_drv;
-       cmpnt->num_dai  = num_dai;
-
-       /*
-        * snd_soc_register_dai()  uses fmt_single_name(), and
-        * snd_soc_register_dais() uses fmt_multiple_name()
-        * for dai->name which is used for name based matching
-        */
-       if (1 == num_dai)
-               ret = snd_soc_register_dai(dev, dai_drv);
-       else
-               ret = snd_soc_register_dais(dev, dai_drv, num_dai);
-       if (ret < 0) {
-               dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret);
-               goto error_component_name;
-       }
-
-       mutex_lock(&client_mutex);
-       list_add(&cmpnt->list, &component_list);
-       mutex_unlock(&client_mutex);
-
-       dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name);
-
-       return ret;
-
-error_component_name:
-       kfree(cmpnt->name);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_register_component);
-
-/**
- * snd_soc_unregister_component - Unregister a component from the ASoC core
- *
- */
-void snd_soc_unregister_component(struct device *dev)
-{
-       struct snd_soc_component *cmpnt;
-
-       list_for_each_entry(cmpnt, &component_list, list) {
-               if (dev == cmpnt->dev)
-                       goto found;
-       }
-       return;
-
-found:
-       snd_soc_unregister_dais(dev, cmpnt->num_dai);
-
-       mutex_lock(&client_mutex);
-       list_del(&cmpnt->list);
-       mutex_unlock(&client_mutex);
-
-       dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name);
-       kfree(cmpnt->name);
-}
-EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
-
 /* Retrieve a card's name from device tree */
 int snd_soc_of_parse_card_name(struct snd_soc_card *card,
                               const char *propname)
@@ -4567,6 +4545,60 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
+int snd_soc_of_get_dai_name(struct device_node *of_node,
+                           const char **dai_name)
+{
+       struct snd_soc_component *pos;
+       struct of_phandle_args args;
+       int ret;
+
+       ret = of_parse_phandle_with_args(of_node, "sound-dai",
+                                        "#sound-dai-cells", 0, &args);
+       if (ret)
+               return ret;
+
+       ret = -EPROBE_DEFER;
+
+       mutex_lock(&client_mutex);
+       list_for_each_entry(pos, &component_list, list) {
+               if (pos->dev->of_node != args.np)
+                       continue;
+
+               if (pos->driver->of_xlate_dai_name) {
+                       ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
+               } else {
+                       int id = -1;
+
+                       switch (args.args_count) {
+                       case 0:
+                               id = 0; /* same as dai_drv[0] */
+                               break;
+                       case 1:
+                               id = args.args[0];
+                               break;
+                       default:
+                               /* not supported */
+                               break;
+                       }
+
+                       if (id < 0 || id >= pos->num_dai) {
+                               ret = -EINVAL;
+                       } else {
+                               *dai_name = pos->dai_drv[id].name;
+                               ret = 0;
+                       }
+               }
+
+               break;
+       }
+       mutex_unlock(&client_mutex);
+
+       of_node_put(args.np);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name);
+
 static int __init snd_soc_init(void)
 {
 #ifdef CONFIG_DEBUG_FS
index c17c14c394df88bb0442ccaf51b5735f05455ab5..2fb0b72d8a3c00c7d6266df72b68487a06f31877 100644 (file)
@@ -59,31 +59,31 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
 /* dapm power sequences - make this per codec in the future */
 static int dapm_up_seq[] = {
        [snd_soc_dapm_pre] = 0,
-       [snd_soc_dapm_supply] = 1,
        [snd_soc_dapm_regulator_supply] = 1,
        [snd_soc_dapm_clock_supply] = 1,
-       [snd_soc_dapm_micbias] = 2,
+       [snd_soc_dapm_supply] = 2,
+       [snd_soc_dapm_micbias] = 3,
        [snd_soc_dapm_dai_link] = 2,
-       [snd_soc_dapm_dai_in] = 3,
-       [snd_soc_dapm_dai_out] = 3,
-       [snd_soc_dapm_aif_in] = 3,
-       [snd_soc_dapm_aif_out] = 3,
-       [snd_soc_dapm_mic] = 4,
-       [snd_soc_dapm_mux] = 5,
-       [snd_soc_dapm_virt_mux] = 5,
-       [snd_soc_dapm_value_mux] = 5,
-       [snd_soc_dapm_dac] = 6,
-       [snd_soc_dapm_switch] = 7,
-       [snd_soc_dapm_mixer] = 7,
-       [snd_soc_dapm_mixer_named_ctl] = 7,
-       [snd_soc_dapm_pga] = 8,
-       [snd_soc_dapm_adc] = 9,
-       [snd_soc_dapm_out_drv] = 10,
-       [snd_soc_dapm_hp] = 10,
-       [snd_soc_dapm_spk] = 10,
-       [snd_soc_dapm_line] = 10,
-       [snd_soc_dapm_kcontrol] = 11,
-       [snd_soc_dapm_post] = 12,
+       [snd_soc_dapm_dai_in] = 4,
+       [snd_soc_dapm_dai_out] = 4,
+       [snd_soc_dapm_aif_in] = 4,
+       [snd_soc_dapm_aif_out] = 4,
+       [snd_soc_dapm_mic] = 5,
+       [snd_soc_dapm_mux] = 6,
+       [snd_soc_dapm_virt_mux] = 6,
+       [snd_soc_dapm_value_mux] = 6,
+       [snd_soc_dapm_dac] = 7,
+       [snd_soc_dapm_switch] = 8,
+       [snd_soc_dapm_mixer] = 8,
+       [snd_soc_dapm_mixer_named_ctl] = 8,
+       [snd_soc_dapm_pga] = 9,
+       [snd_soc_dapm_adc] = 10,
+       [snd_soc_dapm_out_drv] = 11,
+       [snd_soc_dapm_hp] = 11,
+       [snd_soc_dapm_spk] = 11,
+       [snd_soc_dapm_line] = 11,
+       [snd_soc_dapm_kcontrol] = 12,
+       [snd_soc_dapm_post] = 13,
 };
 
 static int dapm_down_seq[] = {
@@ -109,10 +109,10 @@ static int dapm_down_seq[] = {
        [snd_soc_dapm_dai_in] = 10,
        [snd_soc_dapm_dai_out] = 10,
        [snd_soc_dapm_dai_link] = 11,
-       [snd_soc_dapm_clock_supply] = 12,
-       [snd_soc_dapm_regulator_supply] = 12,
        [snd_soc_dapm_supply] = 12,
-       [snd_soc_dapm_post] = 13,
+       [snd_soc_dapm_clock_supply] = 13,
+       [snd_soc_dapm_regulator_supply] = 13,
+       [snd_soc_dapm_post] = 14,
 };
 
 static void pop_wait(u32 pop_time)
@@ -409,6 +409,12 @@ static inline void soc_widget_unlock(struct snd_soc_dapm_widget *w)
                mutex_unlock(&w->platform->mutex);
 }
 
+static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm)
+{
+       if (dapm->codec && dapm->codec->using_regmap)
+               regmap_async_complete(dapm->codec->control_data);
+}
+
 static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w,
        unsigned short reg, unsigned int mask, unsigned int value)
 {
@@ -417,8 +423,9 @@ static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w,
        int ret;
 
        if (w->codec && w->codec->using_regmap) {
-               ret = regmap_update_bits_check(w->codec->control_data,
-                                              reg, mask, value, &change);
+               ret = regmap_update_bits_check_async(w->codec->control_data,
+                                                    reg, mask, value,
+                                                    &change);
                if (ret != 0)
                        return ret;
        } else {
@@ -499,18 +506,22 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
                int val;
                struct soc_mixer_control *mc = (struct soc_mixer_control *)
                        w->kcontrol_news[i].private_value;
-               unsigned int reg = mc->reg;
+               int reg = mc->reg;
                unsigned int shift = mc->shift;
                int max = mc->max;
                unsigned int mask = (1 << fls(max)) - 1;
                unsigned int invert = mc->invert;
 
-               val = soc_widget_read(w, reg);
-               val = (val >> shift) & mask;
-               if (invert)
-                       val = max - val;
+               if (reg != SND_SOC_NOPM) {
+                       val = soc_widget_read(w, reg);
+                       val = (val >> shift) & mask;
+                       if (invert)
+                               val = max - val;
+                       p->connect = !!val;
+               } else {
+                       p->connect = 0;
+               }
 
-               p->connect = !!val;
        }
        break;
        case snd_soc_dapm_mux: {
@@ -1197,6 +1208,8 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w,
 {
        int ret;
 
+       soc_dapm_async_complete(w->dapm);
+
        if (SND_SOC_DAPM_EVENT_ON(event)) {
                if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) {
                        ret = regulator_allow_bypass(w->regulator, false);
@@ -1230,6 +1243,8 @@ int dapm_clock_event(struct snd_soc_dapm_widget *w,
        if (!w->clk)
                return -EIO;
 
+       soc_dapm_async_complete(w->dapm);
+
 #ifdef CONFIG_HAVE_CLK
        if (SND_SOC_DAPM_EVENT_ON(event)) {
                return clk_prepare_enable(w->clk);
@@ -1422,6 +1437,7 @@ static void dapm_seq_check_event(struct snd_soc_card *card,
        if (w->event && (w->event_flags & event)) {
                pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n",
                        w->name, ev_name);
+               soc_dapm_async_complete(w->dapm);
                trace_snd_soc_dapm_widget_event_start(w, event);
                ret = w->event(w, NULL, event);
                trace_snd_soc_dapm_widget_event_done(w, event);
@@ -1494,6 +1510,7 @@ static void dapm_seq_run(struct snd_soc_card *card,
        struct list_head *list, int event, bool power_up)
 {
        struct snd_soc_dapm_widget *w, *n;
+       struct snd_soc_dapm_context *d;
        LIST_HEAD(pending);
        int cur_sort = -1;
        int cur_subseq = -1;
@@ -1524,6 +1541,9 @@ static void dapm_seq_run(struct snd_soc_card *card,
                                                                       cur_subseq);
                        }
 
+                       if (cur_dapm && w->dapm != cur_dapm)
+                               soc_dapm_async_complete(cur_dapm);
+
                        INIT_LIST_HEAD(&pending);
                        cur_sort = -1;
                        cur_subseq = INT_MIN;
@@ -1582,6 +1602,10 @@ static void dapm_seq_run(struct snd_soc_card *card,
                                cur_dapm->seq_notifier(cur_dapm,
                                                       i, cur_subseq);
        }
+
+       list_for_each_entry(d, &card->dapm_list, list) {
+               soc_dapm_async_complete(d);
+       }
 }
 
 static void dapm_widget_update(struct snd_soc_card *card)
@@ -1840,6 +1864,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
                         */
                        switch (w->id) {
                        case snd_soc_dapm_siggen:
+                       case snd_soc_dapm_vmid:
                                break;
                        case snd_soc_dapm_supply:
                        case snd_soc_dapm_regulator_supply:
@@ -2791,7 +2816,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
        struct snd_soc_card *card = codec->card;
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       unsigned int reg = mc->reg;
+       int reg = mc->reg;
        unsigned int shift = mc->shift;
        int max = mc->max;
        unsigned int mask = (1 << fls(max)) - 1;
@@ -2804,7 +2829,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
                         kcontrol->id.name);
 
        mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
-       if (dapm_kcontrol_is_powered(kcontrol))
+       if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM)
                val = (snd_soc_read(codec, reg) >> shift) & mask;
        else
                val = dapm_kcontrol_get_value(kcontrol);
@@ -2835,7 +2860,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
        struct snd_soc_card *card = codec->card;
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       unsigned int reg = mc->reg;
+       int reg = mc->reg;
        unsigned int shift = mc->shift;
        int max = mc->max;
        unsigned int mask = (1 << fls(max)) - 1;
@@ -2857,19 +2882,24 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
 
        mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
 
-       dapm_kcontrol_set_value(kcontrol, val);
+       change = dapm_kcontrol_set_value(kcontrol, val);
+
+       if (reg != SND_SOC_NOPM) {
+               mask = mask << shift;
+               val = val << shift;
 
-       mask = mask << shift;
-       val = val << shift;
+               change = snd_soc_test_bits(codec, reg, mask, val);
+       }
 
-       change = snd_soc_test_bits(codec, reg, mask, val);
        if (change) {
-               update.kcontrol = kcontrol;
-               update.reg = reg;
-               update.mask = mask;
-               update.val = val;
+               if (reg != SND_SOC_NOPM) {
+                       update.kcontrol = kcontrol;
+                       update.reg = reg;
+                       update.mask = mask;
+                       update.val = val;
 
-               card->update = &update;
+                       card->update = &update;
+               }
 
                soc_dapm_mixer_update_power(card, kcontrol, connect);
 
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
new file mode 100644 (file)
index 0000000..b1d7322
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * soc-devres.c  --  ALSA SoC Audio Layer devres functions
+ *
+ * Copyright (C) 2013 Linaro Ltd
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <sound/soc.h>
+
+static void devm_component_release(struct device *dev, void *res)
+{
+       snd_soc_unregister_component(*(struct device **)res);
+}
+
+/**
+ * devm_snd_soc_register_component - resource managed component registration
+ * @dev: Device used to manage component
+ * @cmpnt_drv: Component driver
+ * @dai_drv: DAI driver
+ * @num_dai: Number of DAIs to register
+ *
+ * Register a component with automatic unregistration when the device is
+ * unregistered.
+ */
+int devm_snd_soc_register_component(struct device *dev,
+                        const struct snd_soc_component_driver *cmpnt_drv,
+                        struct snd_soc_dai_driver *dai_drv, int num_dai)
+{
+       struct device **ptr;
+       int ret;
+
+       ptr = devres_alloc(devm_component_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return -ENOMEM;
+
+       ret = snd_soc_register_component(dev, cmpnt_drv, dai_drv, num_dai);
+       if (ret == 0) {
+               *ptr = dev;
+               devres_add(dev, ptr);
+       } else {
+               devres_free(ptr);
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
+
+static void devm_card_release(struct device *dev, void *res)
+{
+       snd_soc_unregister_card(*(struct snd_soc_card **)res);
+}
+
+/**
+ * devm_snd_soc_register_card - resource managed card registration
+ * @dev: Device used to manage card
+ * @card: Card to register
+ *
+ * Register a card with automatic unregistration when the device is
+ * unregistered.
+ */
+int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
+{
+       struct device **ptr;
+       int ret;
+
+       ptr = devres_alloc(devm_card_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return -ENOMEM;
+
+       ret = snd_soc_register_card(card);
+       if (ret == 0) {
+               *ptr = dev;
+               devres_add(dev, ptr);
+       } else {
+               devres_free(ptr);
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(devm_snd_soc_register_card);
index e29ec3cd84b1301febfdf6ecd25d9ed8c2f57c50..0c469cbbe8814f512a6f2f43d0b319cb35088dbd 100644 (file)
@@ -36,6 +36,15 @@ static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p)
        return container_of(p, struct dmaengine_pcm, platform);
 }
 
+static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm,
+       struct snd_pcm_substream *substream)
+{
+       if (!pcm->chan[substream->stream])
+               return NULL;
+
+       return pcm->chan[substream->stream]->device->dev;
+}
+
 /**
  * snd_dmaengine_pcm_prepare_slave_config() - Generic prepare_slave_config callback
  * @substream: PCM substream
@@ -75,12 +84,19 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
        struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
+       int (*prepare_slave_config)(struct snd_pcm_substream *substream,
+                       struct snd_pcm_hw_params *params,
+                       struct dma_slave_config *slave_config);
        struct dma_slave_config slave_config;
        int ret;
 
-       if (pcm->config->prepare_slave_config) {
-               ret = pcm->config->prepare_slave_config(substream, params,
-                               &slave_config);
+       if (!pcm->config)
+               prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
+       else
+               prepare_slave_config = pcm->config->prepare_slave_config;
+
+       if (prepare_slave_config) {
+               ret = prepare_slave_config(substream, params, &slave_config);
                if (ret)
                        return ret;
 
@@ -92,28 +108,54 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream,
        return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
 }
 
-static int dmaengine_pcm_open(struct snd_pcm_substream *substream)
+static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
+       struct device *dma_dev = dmaengine_dma_dev(pcm, substream);
        struct dma_chan *chan = pcm->chan[substream->stream];
+       struct snd_dmaengine_dai_dma_data *dma_data;
+       struct dma_slave_caps dma_caps;
+       struct snd_pcm_hardware hw;
        int ret;
 
-       ret = snd_soc_set_runtime_hwparams(substream,
+       if (pcm->config && pcm->config->pcm_hardware)
+               return snd_soc_set_runtime_hwparams(substream,
                                pcm->config->pcm_hardware);
-       if (ret)
-               return ret;
 
-       return snd_dmaengine_pcm_open(substream, chan);
+       dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
+
+       memset(&hw, 0, sizeof(hw));
+       hw.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
+                       SNDRV_PCM_INFO_INTERLEAVED;
+       hw.periods_min = 2;
+       hw.periods_max = UINT_MAX;
+       hw.period_bytes_min = 256;
+       hw.period_bytes_max = dma_get_max_seg_size(dma_dev);
+       hw.buffer_bytes_max = SIZE_MAX;
+       hw.fifo_size = dma_data->fifo_size;
+
+       ret = dma_get_slave_caps(chan, &dma_caps);
+       if (ret == 0) {
+               if (dma_caps.cmd_pause)
+                       hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME;
+       }
+
+       return snd_soc_set_runtime_hwparams(substream, &hw);
 }
 
-static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm,
-       struct snd_pcm_substream *substream)
+static int dmaengine_pcm_open(struct snd_pcm_substream *substream)
 {
-       if (!pcm->chan[substream->stream])
-               return NULL;
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
+       struct dma_chan *chan = pcm->chan[substream->stream];
+       int ret;
 
-       return pcm->chan[substream->stream]->device->dev;
+       ret = dmaengine_pcm_set_runtime_hwparams(substream);
+       if (ret)
+               return ret;
+
+       return snd_dmaengine_pcm_open(substream, chan);
 }
 
 static void dmaengine_pcm_free(struct snd_pcm *pcm)
@@ -126,6 +168,9 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel(
        struct snd_pcm_substream *substream)
 {
        struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
+       struct snd_dmaengine_dai_dma_data *dma_data;
+
+       dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
 
        if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) && pcm->chan[0])
                return pcm->chan[0];
@@ -134,22 +179,42 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel(
                return pcm->config->compat_request_channel(rtd, substream);
 
        return snd_dmaengine_pcm_request_channel(pcm->config->compat_filter_fn,
-               snd_soc_dai_get_dma_data(rtd->cpu_dai, substream));
+                                                dma_data->filter_data);
 }
 
 static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
 {
        struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
        const struct snd_dmaengine_pcm_config *config = pcm->config;
+       struct device *dev = rtd->platform->dev;
+       struct snd_dmaengine_dai_dma_data *dma_data;
        struct snd_pcm_substream *substream;
+       size_t prealloc_buffer_size;
+       size_t max_buffer_size;
        unsigned int i;
        int ret;
 
+       if (config && config->prealloc_buffer_size) {
+               prealloc_buffer_size = config->prealloc_buffer_size;
+               max_buffer_size = config->pcm_hardware->buffer_bytes_max;
+       } else {
+               prealloc_buffer_size = 512 * 1024;
+               max_buffer_size = SIZE_MAX;
+       }
+
+
        for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) {
                substream = rtd->pcm->streams[i].substream;
                if (!substream)
                        continue;
 
+               dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
+
+               if (!pcm->chan[i] &&
+                   (pcm->flags & SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME))
+                       pcm->chan[i] = dma_request_slave_channel(dev,
+                               dma_data->chan_name);
+
                if (!pcm->chan[i] && (pcm->flags & SND_DMAENGINE_PCM_FLAG_COMPAT)) {
                        pcm->chan[i] = dmaengine_pcm_compat_request_channel(rtd,
                                substream);
@@ -165,8 +230,8 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
                ret = snd_pcm_lib_preallocate_pages(substream,
                                SNDRV_DMA_TYPE_DEV,
                                dmaengine_dma_dev(pcm, substream),
-                               config->prealloc_buffer_size,
-                               config->pcm_hardware->buffer_bytes_max);
+                               prealloc_buffer_size,
+                               max_buffer_size);
                if (ret)
                        goto err_free;
        }
@@ -222,7 +287,9 @@ static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm,
 {
        unsigned int i;
 
-       if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_DT) || !dev->of_node)
+       if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT |
+                          SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) ||
+           !dev->of_node)
                return;
 
        if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) {
index 122c0c18b9dd286ce6322f3ce67bcd070387c913..4f11d23f20621971b8806e70618ee8e4e1c3846f 100644 (file)
@@ -65,31 +65,6 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg)
        return val;
 }
 
-/* Primitive bulk write support for soc-cache.  The data pointed to by
- * `data' needs to already be in the form the hardware expects.  Any
- * data written through this function will not go through the cache as
- * it only handles writing to volatile or out of bounds registers.
- *
- * This is currently only supported for devices using the regmap API
- * wrappers.
- */
-static int snd_soc_hw_bulk_write_raw(struct snd_soc_codec *codec,
-                                    unsigned int reg,
-                                    const void *data, size_t len)
-{
-       /* To ensure that we don't get out of sync with the cache, check
-        * whether the base register is volatile or if we've directly asked
-        * to bypass the cache.  Out of bounds registers are considered
-        * volatile.
-        */
-       if (!codec->cache_bypass
-           && !snd_soc_codec_volatile_register(codec, reg)
-           && reg < codec->driver->reg_cache_size)
-               return -EINVAL;
-
-       return regmap_raw_write(codec->control_data, reg, data, len);
-}
-
 /**
  * snd_soc_codec_set_cache_io: Set up standard I/O functions.
  *
@@ -119,7 +94,6 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
        memset(&config, 0, sizeof(config));
        codec->write = hw_write;
        codec->read = hw_read;
-       codec->bulk_write_raw = snd_soc_hw_bulk_write_raw;
 
        config.reg_bits = addr_bits;
        config.val_bits = data_bits;
index 71358e3b54d93ef10c3e402d98f66773b81d27fc..23d43dac91da2c0d9c6ad8bbf792036483da3fab 100644 (file)
@@ -65,6 +65,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
        struct snd_soc_codec *codec;
        struct snd_soc_dapm_context *dapm;
        struct snd_soc_jack_pin *pin;
+       unsigned int sync = 0;
        int enable;
 
        trace_snd_soc_jack_report(jack, mask, status);
@@ -92,12 +93,16 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
                        snd_soc_dapm_enable_pin(dapm, pin->pin);
                else
                        snd_soc_dapm_disable_pin(dapm, pin->pin);
+
+               /* we need to sync for this case only */
+               sync = 1;
        }
 
        /* Report before the DAPM sync to help users updating micbias status */
        blocking_notifier_call_chain(&jack->notifier, jack->status, jack);
 
-       snd_soc_dapm_sync(dapm);
+       if (sync)
+               snd_soc_dapm_sync(dapm);
 
        snd_jack_report(jack->jack, jack->status);
 
index 330c9a6b5cb5bf9810da6afd76a6cc8155b13845..d4498723b375025cfacc21246f6f018be1c8e321 100644 (file)
@@ -721,7 +721,7 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
        list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients);
        list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients);
 
-       dev_dbg(fe->dev, "  connected new DPCM %s path %s %s %s\n",
+       dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n",
                        stream ? "capture" : "playback",  fe->dai_link->name,
                        stream ? "<-" : "->", be->dai_link->name);
 
@@ -749,7 +749,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe,
                if (dpcm->fe == fe)
                        continue;
 
-               dev_dbg(fe->dev, "  reparent %s path %s %s %s\n",
+               dev_dbg(fe->dev, "reparent %s path %s %s %s\n",
                        stream ? "capture" : "playback",
                        dpcm->fe->dai_link->name,
                        stream ? "<-" : "->", dpcm->be->dai_link->name);
@@ -773,7 +773,7 @@ static void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
                if (dpcm->state != SND_SOC_DPCM_LINK_STATE_FREE)
                        continue;
 
-               dev_dbg(fe->dev, "  freed DSP %s path %s %s %s\n",
+               dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n",
                        stream ? "capture" : "playback", fe->dai_link->name,
                        stream ? "<-" : "->", dpcm->be->dai_link->name);
 
@@ -2116,7 +2116,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 
        pcm->private_free = platform->driver->pcm_free;
 out:
-       dev_info(rtd->card->dev, " %s <-> %s mapping ok\n", codec_dai->name,
+       dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", codec_dai->name,
                cpu_dai->name);
        return ret;
 }
index 29b211e9c06020a641b1449099fc163e58770f87..5e633659c1b38154ebd1a75aa0e4f005b4f089a0 100644 (file)
@@ -75,7 +75,11 @@ static const struct snd_pcm_hardware dummy_dma_hardware = {
 
 static int dummy_dma_open(struct snd_pcm_substream *substream)
 {
-       snd_soc_set_runtime_hwparams(substream, &dummy_dma_hardware);
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
+       /* BE's dont need dummy params */
+       if (!rtd->dai_link->no_pcm)
+               snd_soc_set_runtime_hwparams(substream, &dummy_dma_hardware);
 
        return 0;
 }
index 63acfeb4b69d22e91ab9e98cf81d7fbf9ef4cc04..21a8c954af1cd6dfedd65100cc331d54145f4746 100644 (file)
@@ -257,20 +257,12 @@ static int spdif_in_probe(struct platform_device *pdev)
                return ret;
        }
 
-       return snd_soc_register_component(&pdev->dev, &spdif_in_component,
-                                        &spdif_in_dai, 1);
-}
-
-static int spdif_in_remove(struct platform_device *pdev)
-{
-       snd_soc_unregister_component(&pdev->dev);
-
-       return 0;
+       return devm_snd_soc_register_component(&pdev->dev, &spdif_in_component,
+                                              &spdif_in_dai, 1);
 }
 
 static struct platform_driver spdif_in_driver = {
        .probe          = spdif_in_probe,
-       .remove         = spdif_in_remove,
        .driver         = {
                .name   = "spdif-in",
                .owner  = THIS_MODULE,
index 2fdf68c98d22a92fb53f587919123d069b31a43c..b6ef6f78dc781ad8a45c18d594b1cdc4945647f1 100644 (file)
@@ -280,7 +280,6 @@ static int spdif_out_probe(struct platform_device *pdev)
        struct spdif_out_dev *host;
        struct spear_spdif_platform_data *pdata;
        struct resource *res;
-       int ret;
 
        host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
        if (!host) {
@@ -307,16 +306,8 @@ static int spdif_out_probe(struct platform_device *pdev)
 
        dev_set_drvdata(&pdev->dev, host);
 
-       ret = snd_soc_register_component(&pdev->dev, &spdif_out_component,
-                                        &spdif_out_dai, 1);
-       return ret;
-}
-
-static int spdif_out_remove(struct platform_device *pdev)
-{
-       snd_soc_unregister_component(&pdev->dev);
-
-       return 0;
+       return devm_snd_soc_register_component(&pdev->dev, &spdif_out_component,
+                                              &spdif_out_dai, 1);
 }
 
 #ifdef CONFIG_PM
@@ -357,7 +348,6 @@ static SIMPLE_DEV_PM_OPS(spdif_out_dev_pm_ops, spdif_out_suspend, \
 
 static struct platform_driver spdif_out_driver = {
        .probe          = spdif_out_probe,
-       .remove         = spdif_out_remove,
        .driver         = {
                .name   = "spdif-out",
                .owner  = THIS_MODULE,
index 52af7f6fb37f6938be2845b70cf55d69a7fd12e3..364bf6a907e1c39a36df89ded1d6b2681172940f 100644 (file)
@@ -297,7 +297,7 @@ static bool tegra20_i2s_wr_rd_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static bool tegra20_i2s_volatile_reg(struct device *dev, unsigned int reg)
@@ -310,7 +310,7 @@ static bool tegra20_i2s_volatile_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static bool tegra20_i2s_precious_reg(struct device *dev, unsigned int reg)
@@ -321,7 +321,7 @@ static bool tegra20_i2s_precious_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static const struct regmap_config tegra20_i2s_regmap_config = {
index 551b3c93ce932c77e9e05de4bcf01f5af63d1c94..08bc6931c7c7fc0477703037098a8e7185d7c69d 100644 (file)
@@ -213,7 +213,7 @@ static bool tegra20_spdif_wr_rd_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static bool tegra20_spdif_volatile_reg(struct device *dev, unsigned int reg)
@@ -234,7 +234,7 @@ static bool tegra20_spdif_volatile_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static bool tegra20_spdif_precious_reg(struct device *dev, unsigned int reg)
@@ -247,7 +247,7 @@ static bool tegra20_spdif_precious_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static const struct regmap_config tegra20_spdif_regmap_config = {
index d554d46d08b550788a1bd0ad706f8ed7948a318a..31154338c1eb742da6a1342310d81fddb1f9ecd4 100644 (file)
@@ -100,6 +100,7 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
 {
        int channel;
        u32 reg, val;
+       struct tegra30_ahub_cif_conf cif_conf;
 
        channel = find_first_zero_bit(ahub->rx_usage,
                                      TEGRA30_AHUB_CHANNEL_CTRL_COUNT);
@@ -123,15 +124,21 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
               TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_16;
        tegra30_apbif_write(reg, val);
 
+       cif_conf.threshold = 0;
+       cif_conf.audio_channels = 2;
+       cif_conf.client_channels = 2;
+       cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16;
+       cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16;
+       cif_conf.expand = 0;
+       cif_conf.stereo_conv = 0;
+       cif_conf.replicate = 0;
+       cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_RX;
+       cif_conf.truncate = 0;
+       cif_conf.mono_conv = 0;
+
        reg = TEGRA30_AHUB_CIF_RX_CTRL +
              (channel * TEGRA30_AHUB_CIF_RX_CTRL_STRIDE);
-       val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) |
-             (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) |
-             (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) |
-             TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 |
-             TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16 |
-             TEGRA30_AUDIOCIF_CTRL_DIRECTION_RX;
-       tegra30_apbif_write(reg, val);
+       ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf);
 
        return 0;
 }
@@ -183,6 +190,7 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
 {
        int channel;
        u32 reg, val;
+       struct tegra30_ahub_cif_conf cif_conf;
 
        channel = find_first_zero_bit(ahub->tx_usage,
                                      TEGRA30_AHUB_CHANNEL_CTRL_COUNT);
@@ -206,15 +214,21 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
               TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_16;
        tegra30_apbif_write(reg, val);
 
+       cif_conf.threshold = 0;
+       cif_conf.audio_channels = 2;
+       cif_conf.client_channels = 2;
+       cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16;
+       cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16;
+       cif_conf.expand = 0;
+       cif_conf.stereo_conv = 0;
+       cif_conf.replicate = 0;
+       cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_TX;
+       cif_conf.truncate = 0;
+       cif_conf.mono_conv = 0;
+
        reg = TEGRA30_AHUB_CIF_TX_CTRL +
              (channel * TEGRA30_AHUB_CIF_TX_CTRL_STRIDE);
-       val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) |
-             (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) |
-             (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) |
-             TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 |
-             TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16 |
-             TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX;
-       tegra30_apbif_write(reg, val);
+       ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf);
 
        return 0;
 }
@@ -346,7 +360,7 @@ static bool tegra30_ahub_apbif_wr_rd_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                break;
-       };
+       }
 
        if (REG_IN_ARRAY(reg, CHANNEL_CTRL) ||
            REG_IN_ARRAY(reg, CHANNEL_CLEAR) ||
@@ -381,7 +395,7 @@ static bool tegra30_ahub_apbif_volatile_reg(struct device *dev,
                return true;
        default:
                break;
-       };
+       }
 
        if (REG_IN_ARRAY(reg, CHANNEL_CLEAR) ||
            REG_IN_ARRAY(reg, CHANNEL_STATUS) ||
@@ -437,13 +451,21 @@ static const struct regmap_config tegra30_ahub_ahub_regmap_config = {
 
 static struct tegra30_ahub_soc_data soc_data_tegra30 = {
        .clk_list_mask = CLK_LIST_MASK_TEGRA30,
+       .set_audio_cif = tegra30_ahub_set_cif,
 };
 
 static struct tegra30_ahub_soc_data soc_data_tegra114 = {
        .clk_list_mask = CLK_LIST_MASK_TEGRA114,
+       .set_audio_cif = tegra30_ahub_set_cif,
+};
+
+static struct tegra30_ahub_soc_data soc_data_tegra124 = {
+       .clk_list_mask = CLK_LIST_MASK_TEGRA114,
+       .set_audio_cif = tegra124_ahub_set_cif,
 };
 
 static const struct of_device_id tegra30_ahub_of_match[] = {
+       { .compatible = "nvidia,tegra124-ahub", .data = &soc_data_tegra124 },
        { .compatible = "nvidia,tegra114-ahub", .data = &soc_data_tegra114 },
        { .compatible = "nvidia,tegra30-ahub",  .data = &soc_data_tegra30 },
        {},
@@ -497,6 +519,7 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
        }
        dev_set_drvdata(&pdev->dev, ahub);
 
+       ahub->soc_data = soc_data;
        ahub->dev = &pdev->dev;
 
        ahub->clk_d_audio = clk_get(&pdev->dev, "d_audio");
@@ -669,6 +692,70 @@ static struct platform_driver tegra30_ahub_driver = {
 };
 module_platform_driver(tegra30_ahub_driver);
 
+void tegra30_ahub_set_cif(struct regmap *regmap, unsigned int reg,
+                         struct tegra30_ahub_cif_conf *conf)
+{
+       unsigned int value;
+
+       value = (conf->threshold <<
+                       TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) |
+               ((conf->audio_channels - 1) <<
+                       TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) |
+               ((conf->client_channels - 1) <<
+                       TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) |
+               (conf->audio_bits <<
+                       TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT) |
+               (conf->client_bits <<
+                       TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT) |
+               (conf->expand <<
+                       TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT) |
+               (conf->stereo_conv <<
+                       TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) |
+               (conf->replicate <<
+                       TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT) |
+               (conf->direction <<
+                       TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT) |
+               (conf->truncate <<
+                       TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT) |
+               (conf->mono_conv <<
+                       TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT);
+
+       regmap_write(regmap, reg, value);
+}
+EXPORT_SYMBOL_GPL(tegra30_ahub_set_cif);
+
+void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg,
+                          struct tegra30_ahub_cif_conf *conf)
+{
+       unsigned int value;
+
+       value = (conf->threshold <<
+                       TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) |
+               ((conf->audio_channels - 1) <<
+                       TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) |
+               ((conf->client_channels - 1) <<
+                       TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) |
+               (conf->audio_bits <<
+                       TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT) |
+               (conf->client_bits <<
+                       TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT) |
+               (conf->expand <<
+                       TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT) |
+               (conf->stereo_conv <<
+                       TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) |
+               (conf->replicate <<
+                       TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT) |
+               (conf->direction <<
+                       TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT) |
+               (conf->truncate <<
+                       TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT) |
+               (conf->mono_conv <<
+                       TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT);
+
+       regmap_write(regmap, reg, value);
+}
+EXPORT_SYMBOL_GPL(tegra124_ahub_set_cif);
+
 MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
 MODULE_DESCRIPTION("Tegra30 AHUB driver");
 MODULE_LICENSE("GPL v2");
index 09766cdc45ca76abfb05109d8c7784a72d19372c..d67321d90faa1f5e828e0bca0a5ccc331539f47b 100644 (file)
 #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US   0xf
 #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK      (TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT)
 
+#define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT    24
+#define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US  0x3f
+#define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK     (TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT)
+
 /* Channel count minus 1 */
 #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT     24
 #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US   7
 #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK      (TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT)
 
+/* Channel count minus 1 */
+#define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT    20
+#define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US  0xf
+#define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK     (TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT)
+
 /* Channel count minus 1 */
 #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT    16
 #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US  7
 #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK     (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT)
 
+/* Channel count minus 1 */
+#define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT   16
+#define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US 0xf
+#define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK    (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT)
+
 #define TEGRA30_AUDIOCIF_BITS_4                                0
 #define TEGRA30_AUDIOCIF_BITS_8                                1
 #define TEGRA30_AUDIOCIF_BITS_12                       2
 #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_CH1          (TEGRA30_AUDIOCIF_STEREO_CONV_CH1 << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT)
 #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_AVG          (TEGRA30_AUDIOCIF_STEREO_CONV_AVG << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT)
 
-#define TEGRA30_AUDIOCIF_CTRL_REPLICATE                        3
+#define TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT          3
 
 #define TEGRA30_AUDIOCIF_DIRECTION_TX                  0
 #define TEGRA30_AUDIOCIF_DIRECTION_RX                  1
@@ -468,8 +482,30 @@ extern int tegra30_ahub_set_rx_cif_source(enum tegra30_ahub_rxcif rxcif,
                                          enum tegra30_ahub_txcif txcif);
 extern int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif);
 
+struct tegra30_ahub_cif_conf {
+       unsigned int threshold;
+       unsigned int audio_channels;
+       unsigned int client_channels;
+       unsigned int audio_bits;
+       unsigned int client_bits;
+       unsigned int expand;
+       unsigned int stereo_conv;
+       unsigned int replicate;
+       unsigned int direction;
+       unsigned int truncate;
+       unsigned int mono_conv;
+};
+
+void tegra30_ahub_set_cif(struct regmap *regmap, unsigned int reg,
+                         struct tegra30_ahub_cif_conf *conf);
+void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg,
+                          struct tegra30_ahub_cif_conf *conf);
+
 struct tegra30_ahub_soc_data {
        u32 clk_list_mask;
+       void (*set_audio_cif)(struct regmap *regmap,
+                             unsigned int reg,
+                             struct tegra30_ahub_cif_conf *conf);
        /*
         * FIXME: There are many more differences in HW, such as:
         * - More APBIF channels.
index 47565fd045057344390592bb2a8d7a5374cc2209..231a785b3921a5bd95d87914a92e7f5f2d266a63 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
@@ -179,6 +180,7 @@ static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream,
        struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
        unsigned int mask, val, reg;
        int ret, sample_size, srate, i2sclock, bitcnt;
+       struct tegra30_ahub_cif_conf cif_conf;
 
        if (params_channels(params) != 2)
                return -EINVAL;
@@ -217,21 +219,26 @@ static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream,
 
        regmap_write(i2s->regmap, TEGRA30_I2S_TIMING, val);
 
-       val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) |
-             (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) |
-             (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) |
-             TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 |
-             TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16;
+       cif_conf.threshold = 0;
+       cif_conf.audio_channels = 2;
+       cif_conf.client_channels = 2;
+       cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16;
+       cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16;
+       cif_conf.expand = 0;
+       cif_conf.stereo_conv = 0;
+       cif_conf.replicate = 0;
+       cif_conf.truncate = 0;
+       cif_conf.mono_conv = 0;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_RX;
+               cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_RX;
                reg = TEGRA30_I2S_CIF_RX_CTRL;
        } else {
-               val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX;
+               cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_TX;
                reg = TEGRA30_I2S_CIF_TX_CTRL;
        }
 
-       regmap_write(i2s->regmap, reg, val);
+       i2s->soc_data->set_audio_cif(i2s->regmap, reg, &cif_conf);
 
        val = (1 << TEGRA30_I2S_OFFSET_RX_DATA_OFFSET_SHIFT) |
              (1 << TEGRA30_I2S_OFFSET_TX_DATA_OFFSET_SHIFT);
@@ -369,7 +376,7 @@ static bool tegra30_i2s_wr_rd_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static bool tegra30_i2s_volatile_reg(struct device *dev, unsigned int reg)
@@ -382,7 +389,7 @@ static bool tegra30_i2s_volatile_reg(struct device *dev, unsigned int reg)
                return true;
        default:
                return false;
-       };
+       }
 }
 
 static const struct regmap_config tegra30_i2s_regmap_config = {
@@ -396,9 +403,24 @@ static const struct regmap_config tegra30_i2s_regmap_config = {
        .cache_type = REGCACHE_RBTREE,
 };
 
+static const struct tegra30_i2s_soc_data tegra30_i2s_config = {
+       .set_audio_cif = tegra30_ahub_set_cif,
+};
+
+static const struct tegra30_i2s_soc_data tegra124_i2s_config = {
+       .set_audio_cif = tegra124_ahub_set_cif,
+};
+
+static const struct of_device_id tegra30_i2s_of_match[] = {
+       { .compatible = "nvidia,tegra124-i2s", .data = &tegra124_i2s_config },
+       { .compatible = "nvidia,tegra30-i2s", .data = &tegra30_i2s_config },
+       {},
+};
+
 static int tegra30_i2s_platform_probe(struct platform_device *pdev)
 {
        struct tegra30_i2s *i2s;
+       const struct of_device_id *match;
        u32 cif_ids[2];
        struct resource *mem, *memregion;
        void __iomem *regs;
@@ -412,6 +434,14 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev)
        }
        dev_set_drvdata(&pdev->dev, i2s);
 
+       match = of_match_device(tegra30_i2s_of_match, &pdev->dev);
+       if (!match) {
+               dev_err(&pdev->dev, "Error: No device match found\n");
+               ret = -ENODEV;
+               goto err;
+       }
+       i2s->soc_data = (struct tegra30_i2s_soc_data *)match->data;
+
        i2s->dai = tegra30_i2s_dai_template;
        i2s->dai.name = dev_name(&pdev->dev);
 
@@ -539,11 +569,6 @@ static int tegra30_i2s_resume(struct device *dev)
 }
 #endif
 
-static const struct of_device_id tegra30_i2s_of_match[] = {
-       { .compatible = "nvidia,tegra30-i2s", },
-       {},
-};
-
 static const struct dev_pm_ops tegra30_i2s_pm_ops = {
        SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend,
                           tegra30_i2s_runtime_resume, NULL)
index bea23afe3b9f215f71b3305f065c4902703a74d5..4d0b0a30dbfb341c8a2a93b00485f2d3fb826f18 100644 (file)
 #define TEGRA30_I2S_LCOEF_COEF_MASK_US                 0xffff
 #define TEGRA30_I2S_LCOEF_COEF_MASK                    (TEGRA30_I2S_LCOEF_COEF_MASK_US << TEGRA30_I2S_LCOEF_COEF_SHIFT)
 
+struct tegra30_i2s_soc_data {
+       void (*set_audio_cif)(struct regmap *regmap,
+                             unsigned int reg,
+                             struct tegra30_ahub_cif_conf *conf);
+};
+
 struct tegra30_i2s {
+       const struct tegra30_i2s_soc_data *soc_data;
        struct snd_soc_dai_driver dai;
        int cif_id;
        struct clk *clk_i2s;
index d173880f290d0f762ec0151fb442e815354b8815..1be311c51a181996753c830ac77a902371c0553b 100644 (file)
@@ -182,6 +182,8 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
                data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA30;
        else if (of_machine_is_compatible("nvidia,tegra114"))
                data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA114;
+       else if (of_machine_is_compatible("nvidia,tegra124"))
+               data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA124;
        else {
                dev_err(data->dev, "SoC unknown to Tegra ASoC utils\n");
                return -EINVAL;
index 19fdcafed32f88eb266d34e7f21c51e5d889f729..9577121ce971247407b6d04957de548a5b3fd67d 100644 (file)
@@ -30,6 +30,7 @@ enum tegra_asoc_utils_soc {
        TEGRA_ASOC_UTILS_SOC_TEGRA20,
        TEGRA_ASOC_UTILS_SOC_TEGRA30,
        TEGRA_ASOC_UTILS_SOC_TEGRA114,
+       TEGRA_ASOC_UTILS_SOC_TEGRA124,
 };
 
 struct tegra_asoc_utils_data {
index f056f632557c1c7dc148ca7ce98338e4a03e381e..7b2d23ba69b3bf397ba3fb963feb2d3d2b5948af 100644 (file)
@@ -56,7 +56,6 @@ static const struct snd_pcm_hardware tegra_pcm_hardware = {
 static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = {
        .pcm_hardware = &tegra_pcm_hardware,
        .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
-       .compat_filter_fn = NULL,
        .prealloc_buffer_size = PAGE_SIZE * 8,
 };
 
index ae6b50f9ed56a6c2696d38acee7f8f038d3c9a4c..f65fc0987cfb8cc9bdc45ce366a6c3bfa8641f55 100644 (file)
@@ -28,6 +28,7 @@
 #include "control.h"
 
 #define CNT_INTVAL 0x10000
+#define MASCHINE_BANK_SIZE 32
 
 static int control_info(struct snd_kcontrol *kcontrol,
                        struct snd_ctl_elem_info *uinfo)
@@ -105,6 +106,10 @@ static int control_put(struct snd_kcontrol *kcontrol,
                USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1))
                cmd = EP1_CMD_DIMM_LEDS;
 
+       if (cdev->chip.usb_id ==
+               USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER))
+               cmd = EP1_CMD_DIMM_LEDS;
+
        if (pos & CNT_INTVAL) {
                int i = pos & ~CNT_INTVAL;
 
@@ -121,6 +126,20 @@ static int control_put(struct snd_kcontrol *kcontrol,
                                     usb_sndbulkpipe(cdev->chip.dev, 8),
                                     cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf),
                                     &actual_len, 200);
+               } else if (cdev->chip.usb_id ==
+                       USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER)) {
+
+                       int bank = 0;
+                       int offset = 0;
+
+                       if (i >= MASCHINE_BANK_SIZE) {
+                               bank = 0x1e;
+                               offset = MASCHINE_BANK_SIZE;
+                       }
+
+                       snd_usb_caiaq_send_command_bank(cdev, cmd, bank,
+                                       cdev->control_state + offset,
+                                       MASCHINE_BANK_SIZE);
                } else {
                        snd_usb_caiaq_send_command(cdev, cmd,
                                        cdev->control_state, sizeof(cdev->control_state));
@@ -490,6 +509,74 @@ static struct caiaq_controller kontrols4_controller[] = {
        { "LED: FX2: Mode",                     133 | CNT_INTVAL },
 };
 
+static struct caiaq_controller maschine_controller[] = {
+       { "LED: Pad 1",                         3  | CNT_INTVAL },
+       { "LED: Pad 2",                         2  | CNT_INTVAL },
+       { "LED: Pad 3",                         1  | CNT_INTVAL },
+       { "LED: Pad 4",                         0  | CNT_INTVAL },
+       { "LED: Pad 5",                         7  | CNT_INTVAL },
+       { "LED: Pad 6",                         6  | CNT_INTVAL },
+       { "LED: Pad 7",                         5  | CNT_INTVAL },
+       { "LED: Pad 8",                         4  | CNT_INTVAL },
+       { "LED: Pad 9",                         11 | CNT_INTVAL },
+       { "LED: Pad 10",                        10 | CNT_INTVAL },
+       { "LED: Pad 11",                        9  | CNT_INTVAL },
+       { "LED: Pad 12",                        8  | CNT_INTVAL },
+       { "LED: Pad 13",                        15 | CNT_INTVAL },
+       { "LED: Pad 14",                        14 | CNT_INTVAL },
+       { "LED: Pad 15",                        13 | CNT_INTVAL },
+       { "LED: Pad 16",                        12 | CNT_INTVAL },
+
+       { "LED: Mute",                          16 | CNT_INTVAL },
+       { "LED: Solo",                          17 | CNT_INTVAL },
+       { "LED: Select",                        18 | CNT_INTVAL },
+       { "LED: Duplicate",                     19 | CNT_INTVAL },
+       { "LED: Navigate",                      20 | CNT_INTVAL },
+       { "LED: Pad Mode",                      21 | CNT_INTVAL },
+       { "LED: Pattern",                       22 | CNT_INTVAL },
+       { "LED: Scene",                         23 | CNT_INTVAL },
+
+       { "LED: Shift",                         24 | CNT_INTVAL },
+       { "LED: Erase",                         25 | CNT_INTVAL },
+       { "LED: Grid",                          26 | CNT_INTVAL },
+       { "LED: Right Bottom",                  27 | CNT_INTVAL },
+       { "LED: Rec",                           28 | CNT_INTVAL },
+       { "LED: Play",                          29 | CNT_INTVAL },
+       { "LED: Left Bottom",                   32 | CNT_INTVAL },
+       { "LED: Restart",                       33 | CNT_INTVAL },
+
+       { "LED: Group A",                       41 | CNT_INTVAL },
+       { "LED: Group B",                       40 | CNT_INTVAL },
+       { "LED: Group C",                       37 | CNT_INTVAL },
+       { "LED: Group D",                       36 | CNT_INTVAL },
+       { "LED: Group E",                       39 | CNT_INTVAL },
+       { "LED: Group F",                       38 | CNT_INTVAL },
+       { "LED: Group G",                       35 | CNT_INTVAL },
+       { "LED: Group H",                       34 | CNT_INTVAL },
+
+       { "LED: Auto Write",                    42 | CNT_INTVAL },
+       { "LED: Snap",                          43 | CNT_INTVAL },
+       { "LED: Right Top",                     44 | CNT_INTVAL },
+       { "LED: Left Top",                      45 | CNT_INTVAL },
+       { "LED: Sampling",                      46 | CNT_INTVAL },
+       { "LED: Browse",                        47 | CNT_INTVAL },
+       { "LED: Step",                          48 | CNT_INTVAL },
+       { "LED: Control",                       49 | CNT_INTVAL },
+
+       { "LED: Top Button 1",                  57 | CNT_INTVAL },
+       { "LED: Top Button 2",                  56 | CNT_INTVAL },
+       { "LED: Top Button 3",                  55 | CNT_INTVAL },
+       { "LED: Top Button 4",                  54 | CNT_INTVAL },
+       { "LED: Top Button 5",                  53 | CNT_INTVAL },
+       { "LED: Top Button 6",                  52 | CNT_INTVAL },
+       { "LED: Top Button 7",                  51 | CNT_INTVAL },
+       { "LED: Top Button 8",                  50 | CNT_INTVAL },
+
+       { "LED: Note Repeat",                   58 | CNT_INTVAL },
+
+       { "Backlight Display",                  59 | CNT_INTVAL }
+};
+
 static int add_controls(struct caiaq_controller *c, int num,
                        struct snd_usb_caiaqdev *cdev)
 {
@@ -553,6 +640,11 @@ int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev)
                ret = add_controls(kontrols4_controller,
                        ARRAY_SIZE(kontrols4_controller), cdev);
                break;
+
+       case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
+               ret = add_controls(maschine_controller,
+                       ARRAY_SIZE(maschine_controller), cdev);
+               break;
        }
 
        return ret;
index 1a61dd12fe38a9bb881e462f396e92f43a048e36..bc55f708a696d11a3302e87557fa8dfef15ac5f0 100644 (file)
@@ -235,6 +235,31 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
                           cdev->ep1_out_buf, len+1, &actual_len, 200);
 }
 
+int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev,
+                              unsigned char command,
+                              unsigned char bank,
+                              const unsigned char *buffer,
+                              int len)
+{
+       int actual_len;
+       struct usb_device *usb_dev = cdev->chip.dev;
+
+       if (!usb_dev)
+               return -EIO;
+
+       if (len > EP1_BUFSIZE - 2)
+               len = EP1_BUFSIZE - 2;
+
+       if (buffer && len > 0)
+               memcpy(cdev->ep1_out_buf+2, buffer, len);
+
+       cdev->ep1_out_buf[0] = command;
+       cdev->ep1_out_buf[1] = bank;
+
+       return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
+                          cdev->ep1_out_buf, len+2, &actual_len, 200);
+}
+
 int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev,
                                    int rate, int depth, int bpp)
 {
index ad102fac694221b89a7b0d95f49a5aa225ae8ba9..ab0f7520a99be7e6f835817d31951d19084f5ea3 100644 (file)
@@ -128,5 +128,10 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
                               unsigned char command,
                               const unsigned char *buffer,
                               int len);
+int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev,
+                              unsigned char command,
+                              unsigned char bank,
+                              const unsigned char *buffer,
+                              int len);
 
 #endif /* CAIAQ_DEVICE_H */
index 64952e2d3ed1e94a12ad9e593a15298e8eaceee7..d979050e6a6afbc7daf9b65f666c2de10dbb6269 100644 (file)
@@ -79,7 +79,6 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card *
 /* Vendor/product IDs for this card */
 static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
 static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
-static int nrpacks = 8;                /* max. number of packets per urb */
 static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
 static bool ignore_ctl_error;
 static bool autoclock = true;
@@ -94,8 +93,6 @@ module_param_array(vid, int, NULL, 0444);
 MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
 module_param_array(pid, int, NULL, 0444);
 MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
-module_param(nrpacks, int, 0644);
-MODULE_PARM_DESC(nrpacks, "Max. number of packets per URB.");
 module_param_array(device_setup, int, NULL, 0444);
 MODULE_PARM_DESC(device_setup, "Specific device setup (if needed).");
 module_param(ignore_ctl_error, bool, 0444);
@@ -349,6 +346,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
        case USB_SPEED_LOW:
        case USB_SPEED_FULL:
        case USB_SPEED_HIGH:
+       case USB_SPEED_WIRELESS:
        case USB_SPEED_SUPER:
                break;
        default:
@@ -374,7 +372,6 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
        chip->dev = dev;
        chip->card = card;
        chip->setup = device_setup[idx];
-       chip->nrpacks = nrpacks;
        chip->autoclock = autoclock;
        chip->probing = 1;
 
@@ -754,19 +751,4 @@ static struct usb_driver usb_audio_driver = {
        .supports_autosuspend = 1,
 };
 
-static int __init snd_usb_audio_init(void)
-{
-       if (nrpacks < 1 || nrpacks > MAX_PACKS) {
-               printk(KERN_WARNING "invalid nrpacks value.\n");
-               return -EINVAL;
-       }
-       return usb_register(&usb_audio_driver);
-}
-
-static void __exit snd_usb_audio_cleanup(void)
-{
-       usb_deregister(&usb_audio_driver);
-}
-
-module_init(snd_usb_audio_init);
-module_exit(snd_usb_audio_cleanup);
+module_usb_driver(usb_audio_driver);
index 5ecacaa90b53fc163c9383b18100bb1ce97f1dfe..9867ab866857260df9432b4378d5ba87c1d90834 100644 (file)
@@ -2,11 +2,11 @@
 #define __USBAUDIO_CARD_H
 
 #define MAX_NR_RATES   1024
-#define MAX_PACKS      20
+#define MAX_PACKS      6               /* per URB */
 #define MAX_PACKS_HS   (MAX_PACKS * 8) /* in high speed mode */
-#define MAX_URBS       8
+#define MAX_URBS       12
 #define SYNC_URBS      4       /* always four urbs for sync */
-#define MAX_QUEUE      24      /* try not to exceed this queue length, in ms */
+#define MAX_QUEUE      18      /* try not to exceed this queue length, in ms */
 
 struct audioformat {
        struct list_head list;
@@ -87,6 +87,7 @@ struct snd_usb_endpoint {
        unsigned int phase;             /* phase accumulator */
        unsigned int maxpacksize;       /* max packet size in bytes */
        unsigned int maxframesize;      /* max packet size in frames */
+       unsigned int max_urb_frames;    /* max URB size in frames */
        unsigned int curpacksize;       /* current packet size in bytes (for capture) */
        unsigned int curframesize;      /* current packet size in frames (for capture) */
        unsigned int syncmaxsize;       /* sync endpoint packet size */
@@ -95,7 +96,7 @@ struct snd_usb_endpoint {
        unsigned int syncinterval;      /* P for adaptive mode, 0 otherwise */
        unsigned char silence_value;
        unsigned int stride;
-       int iface, alt_idx;
+       int iface, altsetting;
        int skip_packets;               /* quirks for devices to ignore the first n packets
                                           in a stream */
 
@@ -116,6 +117,8 @@ struct snd_usb_substream {
        unsigned int channels_max;      /* max channels in the all audiofmts */
        unsigned int cur_rate;          /* current rate (for hw_params callback) */
        unsigned int period_bytes;      /* current period bytes (for hw_params callback) */
+       unsigned int period_frames;     /* current frames per period */
+       unsigned int buffer_periods;    /* current periods per buffer */
        unsigned int altset_idx;     /* USB data format: index of alternate setting */
        unsigned int txfr_quirk:1;      /* allow sub-frame alignment */
        unsigned int fmt_type;          /* USB audio format type (1-3) */
@@ -125,6 +128,7 @@ struct snd_usb_substream {
 
        unsigned int hwptr_done;        /* processed byte position in the buffer */
        unsigned int transfer_done;             /* processed frames since last period update */
+       unsigned int frame_limit;       /* limits number of packets in URB */
 
        /* data and sync endpoints for this stream */
        unsigned int ep_num;            /* the endpoint number */
index 93e970f2b3c0ad4d58957faed6b76ec2a1fb2991..b9ba0fcc45df10d4151bb39f8a5d6284dc8ec23e 100644 (file)
@@ -33,7 +33,6 @@
 #include "pcm.h"
 #include "quirks.h"
 
-#define EP_FLAG_ACTIVATED      0
 #define EP_FLAG_RUNNING                1
 #define EP_FLAG_STOPPING       2
 
@@ -426,9 +425,9 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
        list_for_each_entry(ep, &chip->ep_list, list) {
                if (ep->ep_num == ep_num &&
                    ep->iface == alts->desc.bInterfaceNumber &&
-                   ep->alt_idx == alts->desc.bAlternateSetting) {
+                   ep->altsetting == alts->desc.bAlternateSetting) {
                        snd_printdd(KERN_DEBUG "Re-using EP %x in iface %d,%d @%p\n",
-                                       ep_num, ep->iface, ep->alt_idx, ep);
+                                       ep_num, ep->iface, ep->altsetting, ep);
                        goto __exit_unlock;
                }
        }
@@ -447,7 +446,7 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
        ep->type = type;
        ep->ep_num = ep_num;
        ep->iface = alts->desc.bInterfaceNumber;
-       ep->alt_idx = alts->desc.bAlternateSetting;
+       ep->altsetting = alts->desc.bAlternateSetting;
        INIT_LIST_HEAD(&ep->ready_playback_urbs);
        ep_num &= USB_ENDPOINT_NUMBER_MASK;
 
@@ -574,11 +573,14 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
                              snd_pcm_format_t pcm_format,
                              unsigned int channels,
                              unsigned int period_bytes,
+                             unsigned int frames_per_period,
+                             unsigned int periods_per_buffer,
                              struct audioformat *fmt,
                              struct snd_usb_endpoint *sync_ep)
 {
-       unsigned int maxsize, i, urb_packs, total_packs, packs_per_ms;
-       int is_playback = usb_pipeout(ep->pipe);
+       unsigned int maxsize, minsize, packs_per_ms, max_packs_per_urb;
+       unsigned int max_packs_per_period, urbs_per_period, urb_packs;
+       unsigned int max_urbs, i;
        int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels;
 
        if (pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && fmt->dsd_dop) {
@@ -611,58 +613,67 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
        else
                ep->curpacksize = maxsize;
 
-       if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL)
+       if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL) {
                packs_per_ms = 8 >> ep->datainterval;
-       else
-               packs_per_ms = 1;
-
-       if (is_playback && !snd_usb_endpoint_implicit_feedback_sink(ep)) {
-               urb_packs = max(ep->chip->nrpacks, 1);
-               urb_packs = min(urb_packs, (unsigned int) MAX_PACKS);
+               max_packs_per_urb = MAX_PACKS_HS;
        } else {
-               urb_packs = 1;
+               packs_per_ms = 1;
+               max_packs_per_urb = MAX_PACKS;
        }
+       if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep))
+               max_packs_per_urb = min(max_packs_per_urb,
+                                       1U << sync_ep->syncinterval);
+       max_packs_per_urb = max(1u, max_packs_per_urb >> ep->datainterval);
 
-       urb_packs *= packs_per_ms;
+       /*
+        * Capture endpoints need to use small URBs because there's no way
+        * to tell in advance where the next period will end, and we don't
+        * want the next URB to complete much after the period ends.
+        *
+        * Playback endpoints with implicit sync much use the same parameters
+        * as their corresponding capture endpoint.
+        */
+       if (usb_pipein(ep->pipe) ||
+                       snd_usb_endpoint_implicit_feedback_sink(ep)) {
 
-       if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep))
-               urb_packs = min(urb_packs, 1U << sync_ep->syncinterval);
+               /* make capture URBs <= 1 ms and smaller than a period */
+               urb_packs = min(max_packs_per_urb, packs_per_ms);
+               while (urb_packs > 1 && urb_packs * maxsize >= period_bytes)
+                       urb_packs >>= 1;
+               ep->nurbs = MAX_URBS;
 
-       /* decide how many packets to be used */
-       if (is_playback && !snd_usb_endpoint_implicit_feedback_sink(ep)) {
-               unsigned int minsize, maxpacks;
+       /*
+        * Playback endpoints without implicit sync are adjusted so that
+        * a period fits as evenly as possible in the smallest number of
+        * URBs.  The total number of URBs is adjusted to the size of the
+        * ALSA buffer, subject to the MAX_URBS and MAX_QUEUE limits.
+        */
+       } else {
                /* determine how small a packet can be */
-               minsize = (ep->freqn >> (16 - ep->datainterval))
-                         * (frame_bits >> 3);
+               minsize = (ep->freqn >> (16 - ep->datainterval)) *
+                               (frame_bits >> 3);
                /* with sync from device, assume it can be 12% lower */
                if (sync_ep)
                        minsize -= minsize >> 3;
                minsize = max(minsize, 1u);
-               total_packs = (period_bytes + minsize - 1) / minsize;
-               /* we need at least two URBs for queueing */
-               if (total_packs < 2) {
-                       total_packs = 2;
-               } else {
-                       /* and we don't want too long a queue either */
-                       maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2);
-                       total_packs = min(total_packs, maxpacks);
-               }
-       } else {
-               while (urb_packs > 1 && urb_packs * maxsize >= period_bytes)
-                       urb_packs >>= 1;
-               total_packs = MAX_URBS * urb_packs;
-       }
 
-       ep->nurbs = (total_packs + urb_packs - 1) / urb_packs;
-       if (ep->nurbs > MAX_URBS) {
-               /* too much... */
-               ep->nurbs = MAX_URBS;
-               total_packs = MAX_URBS * urb_packs;
-       } else if (ep->nurbs < 2) {
-               /* too little - we need at least two packets
-                * to ensure contiguous playback/capture
-                */
-               ep->nurbs = 2;
+               /* how many packets will contain an entire ALSA period? */
+               max_packs_per_period = DIV_ROUND_UP(period_bytes, minsize);
+
+               /* how many URBs will contain a period? */
+               urbs_per_period = DIV_ROUND_UP(max_packs_per_period,
+                               max_packs_per_urb);
+               /* how many packets are needed in each URB? */
+               urb_packs = DIV_ROUND_UP(max_packs_per_period, urbs_per_period);
+
+               /* limit the number of frames in a single URB */
+               ep->max_urb_frames = DIV_ROUND_UP(frames_per_period,
+                                       urbs_per_period);
+
+               /* try to use enough URBs to contain an entire ALSA buffer */
+               max_urbs = min((unsigned) MAX_URBS,
+                               MAX_QUEUE * packs_per_ms / urb_packs);
+               ep->nurbs = min(max_urbs, urbs_per_period * periods_per_buffer);
        }
 
        /* allocate and initialize data urbs */
@@ -670,8 +681,7 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
                struct snd_urb_ctx *u = &ep->urb[i];
                u->index = i;
                u->ep = ep;
-               u->packets = (i + 1) * total_packs / ep->nurbs
-                       - i * total_packs / ep->nurbs;
+               u->packets = urb_packs;
                u->buffer_size = maxsize * u->packets;
 
                if (fmt->fmt_type == UAC_FORMAT_TYPE_II)
@@ -703,8 +713,7 @@ out_of_memory:
 /*
  * configure a sync endpoint
  */
-static int sync_ep_set_params(struct snd_usb_endpoint *ep,
-                             struct audioformat *fmt)
+static int sync_ep_set_params(struct snd_usb_endpoint *ep)
 {
        int i;
 
@@ -748,6 +757,8 @@ out_of_memory:
  * @pcm_format: the audio fomat.
  * @channels: the number of audio channels.
  * @period_bytes: the number of bytes in one alsa period.
+ * @period_frames: the number of frames in one alsa period.
+ * @buffer_periods: the number of periods in one alsa buffer.
  * @rate: the frame rate.
  * @fmt: the USB audio format information
  * @sync_ep: the sync endpoint to use, if any
@@ -760,6 +771,8 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
                                snd_pcm_format_t pcm_format,
                                unsigned int channels,
                                unsigned int period_bytes,
+                               unsigned int period_frames,
+                               unsigned int buffer_periods,
                                unsigned int rate,
                                struct audioformat *fmt,
                                struct snd_usb_endpoint *sync_ep)
@@ -793,10 +806,11 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
        switch (ep->type) {
        case  SND_USB_ENDPOINT_TYPE_DATA:
                err = data_ep_set_params(ep, pcm_format, channels,
-                                        period_bytes, fmt, sync_ep);
+                                        period_bytes, period_frames,
+                                        buffer_periods, fmt, sync_ep);
                break;
        case  SND_USB_ENDPOINT_TYPE_SYNC:
-               err = sync_ep_set_params(ep, fmt);
+               err = sync_ep_set_params(ep);
                break;
        default:
                err = -EINVAL;
@@ -931,28 +945,21 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep)
  *
  * @ep: the endpoint to deactivate
  *
- * If the endpoint is not currently in use, this functions will select the
- * alternate interface setting 0 for the interface of this endpoint.
+ * If the endpoint is not currently in use, this functions will
+ * deactivate its associated URBs.
  *
  * In case of any active users, this functions does nothing.
- *
- * Returns an error if usb_set_interface() failed, 0 in all other
- * cases.
  */
-int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep)
+void snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep)
 {
        if (!ep)
-               return -EINVAL;
-
-       deactivate_urbs(ep, true);
-       wait_clear_urbs(ep);
+               return;
 
        if (ep->use_count != 0)
-               return 0;
-
-       clear_bit(EP_FLAG_ACTIVATED, &ep->flags);
+               return;
 
-       return 0;
+       deactivate_urbs(ep, true);
+       wait_clear_urbs(ep);
 }
 
 /**
index 2287adf5ca597b65156f1dbbffca609774b84c00..1c7e8ee48abc12e3e61cbda6491f20bdb9628ce5 100644 (file)
@@ -12,6 +12,8 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
                                snd_pcm_format_t pcm_format,
                                unsigned int channels,
                                unsigned int period_bytes,
+                               unsigned int period_frames,
+                               unsigned int buffer_periods,
                                unsigned int rate,
                                struct audioformat *fmt,
                                struct snd_usb_endpoint *sync_ep);
@@ -20,7 +22,7 @@ int  snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep);
 void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep);
 void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
 int  snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
-int  snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep);
+void snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep);
 void snd_usb_endpoint_free(struct list_head *head);
 
 int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep);
index 620902463c6ea2d5b9ba8eec496c33b5c8e78c2a..51ed1ac825fdca80744a1351de727bdc4fddbfbe 100644 (file)
@@ -118,6 +118,7 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,
 {
        switch (snd_usb_get_speed(chip->dev)) {
        case USB_SPEED_HIGH:
+       case USB_SPEED_WIRELESS:
        case USB_SPEED_SUPER:
                if (get_endpoint(alts, 0)->bInterval >= 1 &&
                    get_endpoint(alts, 0)->bInterval <= 4)
index 95558ef4a7a09c72ed52c4706348d765a40c4314..44b0ba4feab3bd1b43100feb457e82e290ea26dc 100644 (file)
@@ -1151,14 +1151,14 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl,
        const char *names_to_check[] = {
                "Headset", "headset", "Headphone", "headphone", NULL};
        const char **s;
-       bool found = 0;
+       bool found = false;
 
        if (strcmp("Speaker", kctl->id.name))
                return;
 
        for (s = names_to_check; *s; s++)
                if (strstr(card->shortname, *s)) {
-                       found = 1;
+                       found = true;
                        break;
                }
 
index b375d58871e7ce9f7eb0e63a3f73644984c6c5e1..ca3256d6fde3d1206ffe3fc7313305561438f611 100644 (file)
@@ -241,16 +241,17 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
                struct snd_usb_endpoint *ep = subs->sync_endpoint;
 
                if (subs->data_endpoint->iface != subs->sync_endpoint->iface ||
-                   subs->data_endpoint->alt_idx != subs->sync_endpoint->alt_idx) {
+                   subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) {
                        err = usb_set_interface(subs->dev,
                                                subs->sync_endpoint->iface,
-                                               subs->sync_endpoint->alt_idx);
+                                               subs->sync_endpoint->altsetting);
                        if (err < 0) {
+                               clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags);
                                snd_printk(KERN_ERR
                                           "%d:%d:%d: cannot set interface (%d)\n",
                                           subs->dev->devnum,
                                           subs->sync_endpoint->iface,
-                                          subs->sync_endpoint->alt_idx, err);
+                                          subs->sync_endpoint->altsetting, err);
                                return -EIO;
                        }
                }
@@ -282,22 +283,6 @@ static void stop_endpoints(struct snd_usb_substream *subs, bool wait)
        }
 }
 
-static int deactivate_endpoints(struct snd_usb_substream *subs)
-{
-       int reta, retb;
-
-       reta = snd_usb_endpoint_deactivate(subs->sync_endpoint);
-       retb = snd_usb_endpoint_deactivate(subs->data_endpoint);
-
-       if (reta < 0)
-               return reta;
-
-       if (retb < 0)
-               return retb;
-
-       return 0;
-}
-
 static int search_roland_implicit_fb(struct usb_device *dev, int ifnum,
                                     unsigned int altsetting,
                                     struct usb_host_interface **alts,
@@ -595,6 +580,7 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs)
                                                   subs->pcm_format,
                                                   subs->channels,
                                                   subs->period_bytes,
+                                                  0, 0,
                                                   subs->cur_rate,
                                                   subs->cur_audiofmt,
                                                   NULL);
@@ -631,6 +617,7 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs)
                                          subs->pcm_format,
                                          sync_fp->channels,
                                          sync_period_bytes,
+                                         0, 0,
                                          subs->cur_rate,
                                          sync_fp,
                                          NULL);
@@ -653,6 +640,8 @@ static int configure_endpoint(struct snd_usb_substream *subs)
                                          subs->pcm_format,
                                          subs->channels,
                                          subs->period_bytes,
+                                         subs->period_frames,
+                                         subs->buffer_periods,
                                          subs->cur_rate,
                                          subs->cur_audiofmt,
                                          subs->sync_endpoint);
@@ -689,6 +678,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
 
        subs->pcm_format = params_format(hw_params);
        subs->period_bytes = params_period_bytes(hw_params);
+       subs->period_frames = params_period_size(hw_params);
+       subs->buffer_periods = params_periods(hw_params);
        subs->channels = params_channels(hw_params);
        subs->cur_rate = params_rate(hw_params);
 
@@ -730,7 +721,8 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
        down_read(&subs->stream->chip->shutdown_rwsem);
        if (!subs->stream->chip->shutdown) {
                stop_endpoints(subs, true);
-               deactivate_endpoints(subs);
+               snd_usb_endpoint_deactivate(subs->sync_endpoint);
+               snd_usb_endpoint_deactivate(subs->data_endpoint);
        }
        up_read(&subs->stream->chip->shutdown_rwsem);
        return snd_pcm_lib_free_vmalloc_buffer(substream);
@@ -1363,6 +1355,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
        frames = 0;
        urb->number_of_packets = 0;
        spin_lock_irqsave(&subs->lock, flags);
+       subs->frame_limit += ep->max_urb_frames;
        for (i = 0; i < ctx->packets; i++) {
                if (ctx->packet_size[i])
                        counts = ctx->packet_size[i];
@@ -1377,6 +1370,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
                subs->transfer_done += counts;
                if (subs->transfer_done >= runtime->period_size) {
                        subs->transfer_done -= runtime->period_size;
+                       subs->frame_limit = 0;
                        period_elapsed = 1;
                        if (subs->fmt_type == UAC_FORMAT_TYPE_II) {
                                if (subs->transfer_done > 0) {
@@ -1399,8 +1393,10 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
                                break;
                        }
                }
-               if (period_elapsed &&
-                   !snd_usb_endpoint_implicit_feedback_sink(subs->data_endpoint)) /* finish at the period boundary */
+               /* finish at the period boundary or after enough frames */
+               if ((period_elapsed ||
+                               subs->transfer_done >= subs->frame_limit) &&
+                   !snd_usb_endpoint_implicit_feedback_sink(ep))
                        break;
        }
        bytes = frames * ep->stride;
index caabe9b3af49250460d9a3b7e44e5896fea64c9a..5d2fe0530745a175c24a9034416a29477be96062 100644 (file)
@@ -55,7 +55,6 @@ struct snd_usb_audio {
        struct list_head mixer_list;    /* list of mixer interfaces */
 
        int setup;                      /* from the 'device_setup' module param */
-       int nrpacks;                    /* from the 'nrpacks' module param */
        bool autoclock;                 /* from the 'autoclock' module param */
 
        struct usb_host_interface *ctrl_intf;   /* the audio control interface */
index 4fa655d68a81c8a1b8dd8b60f885721edc7cfea1..41bd85559d4b01aa8ee0e89615ece47c4115b0d0 100644 (file)
@@ -151,7 +151,7 @@ static int check_timer_create(int which)
        fflush(stdout);
 
        done = 0;
-       timer_create(which, NULL, &id);
+       err = timer_create(which, NULL, &id);
        if (err < 0) {
                perror("Can't create timer\n");
                return -1;
This page took 0.363977 seconds and 5 git commands to generate.