regmap: assume registers are volatile iff no cache

If a regmap has a cache, it's likely that registers are not volatile,
perhaps with exceptions. Otherwise, the cache would not be useful. Encode
this assumption into regmap_volatile()'s default return value, for the
case where a regmap doesn't specify which registers are volatile.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ASoC: dapm: check suspend state in dapm_dai_check_power()

Currently, when the system enters suspend with audio playing, since the
DAI widgets are active, the associated CODEC is considered active, and
hence is not transition into a low-power bias state as the system
suspends. This likely causes audio failure after resume, since the CODEC
power has quite possibly been removed during suspend, and the bias level
transitions in the CODEC driver are needed to recover from this. At the
very least, this issue likely causes warnings in the kernel log due to
the CODEC being left on over the suspend transition.

To solve this, modify dapm_dai_check_power() not to consider DAI widgets
active if the system is entering suspend.

Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
ASoC: tegra: implement suspend/resume for Tegra30 AHUB

Add tegra30_ahub_{suspend,resume}. These use regcache functions to
restore all HW registers after power loss during a suspend/resume cycle.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ASoC: tegra: implement suspend/resume for Tegra30 I2S

Add tegra30_i2s_{suspend,resume}. These use regcache functions to
restore all HW registers after power loss during a suspend/resume cycle.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: call disable_nonboot_cpus() from machine_shutdown()

On Tegra at least, this change allows kexec to work with SMP enabled.
Without this,  machine_shutdown() simply puts all CPUs into a loop. If
the code of that loop is over-written, the CPUs may hang or crash (which
I do observe in practice), or cause the kexec'd kernel not to be able to
initialize them.

This fix has the added benefit that the kexec always happens on the boot
CPU, and thus kexec mirrors the initial kernel boot as much as possible.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Will Deacon <will.deacon@arm.com>
BROKEN: ARM: tegra: trimslice: enable DVI port

The DVI port is driven from the "RGB" port, via a DVI encoder chip.

BROKEN:
* Booting with just DVI plugged in yields a signal the monitor can't sync to.
* Booting with HDMI, then moving the cable to DVI yields incorrect colors and
  a lower resolution than the panel's native resolution (1024x768@67Hz!).

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
[swarren: extracted from a larger patch by Thierry]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
BROKEN: ARM: tegra: cardhu: enable HDMI port

BROKEN because the only bootloaders we have already enable the LCD scanout,
and dual-display stresses the memory bandwidth too much, because the memory
controller programming is way off on Cardhu right now.

Signed-off-by: Mark Zhang <markz@nvidia.com>
[swarren: extracted from a larger patch by Mark]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Revert "BROKEN: ARM: tegra: cardhu: enable HDMI port"

This reverts commit 17c37e0079ade1e6140002dd4ef0f79e08f185c9.
HACK: ARM: dt: tegra: cardhu: Enable LCD panel

HACK: it's missing any of the panel/backlight control GPIOs etc.

Signed-off-by: Mark Zhang <markz@nvidia.com>
[swarren: extracted from a larger patch by Mark]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
LOCAL HACK: tegra_defconfig changes

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: bluetooth testing hacks for Cardhu

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ASoC: add RT5640 CODEC driver

Note: This driver was originally written by Johnny Hsu at Realtek
according to comment in the file. Hence, the git author field contains
Johnny's name. However, the driver was provided as a .zip file without
any signed-off-by line. When I contacted Realtek to obtain one, Bard
responded with his, hence it is included below. Since they work for the
same company, I assume this is acceptable.

This driver is based on a copy Realtek gave NVIDIA over 2 years ago, plus
some fixes NVIDIA applied internally, plus various cleanup I (swarren)
performed during upstreaming. Realtek does have a newer base version of
this driver, but the speakers don't appear to work in that version, so
I ignored it for now. Hopefully, the changes in that driver will trickle
upstream after this.

I (swarren) made the following changes relative to downstream, so I
should be blamed for:
* Replaced separate HPOL MIX and HPOR MIX with a single HPO MIX, since
  there is only 1 control in HW. This change was taken from Realtek's
  latest driver.
* Replaced SND_SOC_DAPM_MICBIAS with SND_SOC_DAPM_SUPPLY, although I
  can't test this yet.
* Renamed Mono outputs to MONO to match documentation and be consistent
  with all other inputs/outputs. Renamed micbias inputs to MICBIAS too.
* Trimmed down the register init table to remove entries that duplicate
  ASoC widgets. Added a couple missing widgets (Speaker Playback Switch,
  Speaker Channel Switch, HP Channel Switch) to support this.
* Removed support for RT5643, since I can't test that.
* Removed support for rt5640_headset_detect(), since I can't test it, and
  the style doesn't seem to match what I've seen in other CODECs.
* Update probe() to call rt5640_set_bias_level() to avoid duplicate code.
* Minor changes to adapt to recent kernel changes:
  * Make use of module_i2c_driver.
  * Remove use of devinit/devexit.
* Removed a bunch of ifdef'd and dead code.
* Formatting, checkpatch, and warning fixes.

I've tested playback to the speaker and headphone outputs, but not:
* The "OUT" output.
* Any capture path.

Cc: Bard Liao <bardliao@realtek.com>
Cc: Johnny Hsu <johnnyhsu@realtek.com>
Cc: Oder Chiou <oder_chiou@realtek.com>
Cc: Flove <flove@realtek.com>
Signed-off-by: Bard Liao <bardliao@realtek.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2:
* Make use of new "mixer control sharing" feature for HPO MIX L/R.

Mark, a couple questions:
* Is the custom index_reg device attr file OK, or should I remove that?
* Do new CODEC drivers have to use regmap directly, or is using the ASoC
  IO system still OK?
ASoC: tegra: add tegra+RT5640 machine driver

FIXME: describe this

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: enable audio on Dalmore

Dalmore uses the RT5640 audio CODEC. Instantiate this on the I2C bus.
Enable the relevant Tegra I2C controller. Add the top-level "sound" node
to hook everything together, and provide a "sound card" device.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: defconfig updates for audio on Dalmore

Enable the ASoC machine driver that is required for audio on Dalmore.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
HACK: Attempt to get DMICs working
ARM: tegra: enable audio on Beaver

FIXME: Need to run "gpio set 186" in U-Boot before booting the kernel,
to enable LDO1_EN to get the CODEC to show up on the I2C bus.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: disable LP2 cpuidle state if PCIe is enabled

Tegra20 HW appears to have a bug such that PCIe device interrupts, whether
they are legacy IRQs or MSI, are lost when LP2 is enabled. To work around
this, simply disable LP2 if the PCI driver and DT node are both enabled.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: Set state.disable rather than fiddling with .state_count. This is
more flexible.
usb: phy: export ulpi_viewport_access_ops

In order to build a ULPI PHY driver as a module, this symbol needs to
be exported.

Signed-off-by: Manjunath Goudar <manjunath.goudar@linaro.org>
[swarren, reworked Manjunath's patches to split them more logically]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
usb: phy: add MODULE_LICENSE to phy-tegra-usb.c

When this file is built as a module, it needs a MODULE_LICENSE in order
to access many exported symbols.

Signed-off-by: Stephen Warren <swarren@nvidia.com>