ASoC: free jack GPIOs before the sound card is freed

This is the same change as commit fb6b8e71448a "ASoC: tegra: free jack
GPIOs before the sound card is freed", but applied to all other ASoC
machine drivers where code inspection indicates the same problem exists.

That commit's description is:
==========
snd_soc_jack_add_gpios() schedules a work queue item to poll the GPIO to
generate an initial jack status report. If sound card initialization
fails, that work item needs to be cancelled, so it doesn't run after the
card has been freed. Specifically, freeing the card calls
snd_jack_dev_free() which calls snd_jack_dev_disconnect() which sets
jack->input_dev = NULL, and input_dev is used by snd_jack_report(), which
is called from the work queue item.

snd_soc_jack_free_gpios() cancels the work item. The Tegra ASoC machine
drivers do call this function in the platform driver remove() callback.
However, this happens after the sound card is freed, at least when the
card is freed due to errors late during snd_soc_instantiate_card(). This
leaves a window where the work item can execute after the card is freed.
In next-20140522, sound card initialization does fail for unrelated
reasons, and hits the problem described above.

To solve this, fix the Tegra ASoC machine drivers to clean up the Jack
GPIOs during the snd_soc_card's .remove() callback, which is executed
before the overall card object is freed. also, guard the cleanup call
based on whether we actually setup up the GPIOs in the first place.
Ideally, we'd do the cleanup in a struct snd_soc_dai_link .fini/remove
function to match where the GPIOs get set up. However, there is no such
callback.
==========

Note that I have not even compile-tested this in most cases, since most
of the drivers rely on specific mach-* support I don't have enabled, and
don't support COMPILE_TEST. Testing by the relevant board maintainers
would be useful.

Cc: Peter Ujfalusi <peter.ujfalusi@ti.com> (maintainer:OMAP AUDIO SUPPORT)
Cc: Jarkko Nikula <jarkko.nikula@bitmer.com> (maintainer:OMAP AUDIO SUPPORT)
Cc: Philipp Zabel <philipp.zabel@gmail.com> (maintainer:ARM/H4700 (HP IPA...)
Cc: Paul Parsons <lost.distance@yahoo.com> (maintainer:ARM/H4700 (HP IPA...)
Cc: Eric Miao <eric.y.miao@gmail.com> (maintainer:PXA2xx/PXA3xx SUP...)
Cc: Russell King <linux@arm.linux.org.uk> (maintainer:PXA2xx/PXA3xx SUP...)
Cc: Haojian Zhuang <haojian.zhuang@gmail.com> (maintainer:PXA2xx/PXA3xx SUP...)
Cc: Ben Dooks <ben-linux@fluff.org> (maintainer:ARM/SAMSUNG ARM A...)
Cc: Kukjin Kim <kgene.kim@samsung.com> (maintainer:ARM/SAMSUNG ARM A...)
Cc: Sangbeom Kim <sbkim73@samsung.com> (supporter:SAMSUNG AUDIO (AS...)
Cc: linux-omap@vger.kernel.org (open list:OMAP AUDIO SUPPORT)
Cc: linux-samsung-soc@vger.kernel.org (moderated list:ARM/SAMSUNG ARM A...)
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
Mark, do you need this patch split up by architecture for topic branches?
I assume not if you've already sent your pull requests. This applies fine
on top of tag asoc-v3.16.
Input: atmel_mxt_ts - download device config using firmware loader

The existing implementation which encodes the configuration as a binary
blob in platform data is unsatisfactory since it requires a kernel
recompile for the configuration to be changed, and it doesn't deal well
with firmware changes that move values around on the chip.

Atmel define an ASCII format for the configuration which can be exported
from their tools. This patch implements a parser for that format which
loads the configuration via the firmware loader and sends it to the MXT
chip.

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Input: atmel_mxt_ts - calculate and check CRC in config file

By validating the checksum, we can identify if the configuration is
corrupt.  In addition, this patch writes the configuration in a short
series of block writes rather than as many individual values.

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Input: atmel_mxt_ts - use deep sleep mode when stopped

By writing zero to both the active and idle cycle times the maXTouch device
is put into a deep sleep mode when it consumes minimal power. It is
unnecessary to change the configuration of any other objects (for example
to disable T9 touchscreen).

It is counterproductive to reset the chip on resume, it will result in a
long delay. However it is necessary to issue a calibrate command after the
chip has spent any time in deep sleep.

This patch also deals with the situation where the power configuration is
zero on probe, which would mean that the device never wakes up to execute
commands.

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Input: atmel_mxt_ts - Set pointer emulation on touchpads

Touchpads are pointers, so make sure to pass the correct values to
input_mt_report_pointer_emulation(). Without this, tap-to-click doesn't
work.

There used to be an explicit is_tp field indicating whether the device
is a touchpad or touch screen. Not-yet-committed patch "Input:
atmel_mxt_ts - improve T19 GPIO keys handling" removed it, and replaced
usage with pdata->t19_num_keys instead. Hence, this commit does the same.
I don't know enough about T19 GPIO keys to know if this is the correct
data to drive this decision.

Signed-off-by: Benson Leung <bleung@chromium.org>
[swarren, reworked commit for upstream, and rewrote the commit description
since the downstream version concentrated on patch rebase history rather
than the functionality]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Input: atmel_mxt_ts: define a device tree binding

This document describes how to represent an Atmel MXT touchpad in device
tree.

The device may show up in bootloader mode if reset by SW, or if
configuration/firmware is missing. Or, it may present itself as the final
touchpad device. These modes have different I2C addresses, and hence
different I2C nodes with different compatible values representing their
feature-set.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Input: atmel_mxt_ts: implement device tree parsing

If platform data is missing, and the device was instantiated via device
tree, parse the DT to generate the platform data.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: add touchpad to Venice2 DT

The touchpad is an Atmel MXT device. The device may show up in bootloader
mode if reset by SW, or if configuration/firmware is missing. Or, it may
present itself as the final touchpad device. These modes have different
I2C addresses, and hence different I2C nodes.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: disable Atmel MXT bootloader node

I think this isn't needed...

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: enable Atmel touchpad in defconfig

This driver is used on Venice2 for the touchpad.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Revert "ARM: tegra: enable Atmel touchpad in defconfig"

The driver doesn't work right now:-(

This reverts commit d58d451f9619bd91aa0e2d94af689535f024643c.
ARM: tegra: add light sensor to Venice2 DT

FIXME:
dmesg|grep -i isl
[    1.765974] isl29018 1-0044: No cache defaults, reading back from HW
[    1.772624] isl29018 1-0044: regmap initialization failed: -121
[    1.778637] isl29018: probe of 1-0044 failed with error -121

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: jetson-tk1: don't set mux func for GPIOs

When a Tegra pin is configured as a GPIO, the selected mux function is
irrelevant. Since we don't need to set the function for those pins,
don't do it!

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: update Venice2 pinmux

This re-imports the entire Venice2 pinmux data from the board's master
spreadsheet, thus tieing it to the primary definition of what is correct
for this board.

This also applies the same change as the previous patch does for Jetson
TK1: When a Tegra pin is configured as a GPIO, the selected mux function
is irrelevant. Since we don't need to set the function for those pins,
don't do it!

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: rebuild tegra_defconfig on next-20140520

This makes it easier to create isolated defconfig patches

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Rebuild multi_v7_defconfig on next-20140520

Signed-off-by: Stephen Warren <swarren@nvidia.com>
LOCAL HACK: tegra_defconfig changes

Signed-off-by: Stephen Warren <swarren@nvidia.com>
WIP: ARM: tegra: venice2 WiFi

Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: Add the EC i2c tunnel to tegra124-venice2

This adds the EC i2c tunnel (and devices under it) to the
tegra124-venice2 device tree.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
ARM: tegra: defconfig updates for cros_ec SPI/I2C bridge

These devices exist on the Tegra Venice2 board, behind the recently
added SPI->EC->I2C bridge.

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