gpio: palmas: add dt support

Add of_device_id table for Palma GPIO to be enable the
driver from DT file.

The driver can be registered from DT file as:
	palmas: tps65913@58 {
		:::::::::::
		palmas_gpio: palmas_gpio {
			compatible = "ti,palmas-gpio";
			gpio-controller;
			#gpio-cells = <2>;
		};
	};

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
(info initial version posted 3/21/13, no reviews yet)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: gpio: tegra: add gpio wakeup source handling

This patch add the gpio wakeup source handling for the Tegra platform. It
was be done by enabling the irq for the gpio in the gpio controller and
enabling the bank irq of the gpio in the Tegra legacy irq controller when
the system going to suspend.

Based on the work by:
Varun Wadekar <vwadekar@nvidia.com>

Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Joseph Lo <josephl@nvidia.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
(cherry picked from commit 203f31cb86eb6aa4c49711e7ca25a7660efc39b8)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra: assume CONFIG_OF in tegra_asoc_utils_init

Tegra only supports, and always enables, device tree. Remove all runtime
checks for DT support from the driver.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
(cherry picked from commit 2c835bafdc53e3b3b7babb67685163531674d9df)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra_wm8753: minor cleanup

Various minor cleanups so that the probe() body more closely resembles
other drivers, for easier comparison.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit bddd7d0230deb3fbc2cb32e0af04f7cf46397e9e)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra: add tegra machine driver using wm9712 codec

This adds a very simple machine driver using the Wolfson wm9712 AC97
codec.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 6995b8cb9622bf574ac6f309e69288e7d0f76ece)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra_wm9712: Remove __devinitconst attribute

This has been removed from the kernel recently and gives following build errors:
sound/soc/tegra/tegra_wm9712.c:155:58: error:
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__devinitconst’
sound/soc/tegra/tegra_wm9712.c:165:21: error:
‘tegra_wm9712_of_match’ undeclared here (not in a function)

Cc: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit b10fedf89269a444ddfc92371acc9721749e8b41)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra_wm9712: assume CONFIG_OF

Tegra only supports, and always enables, device tree. Remove all runtime
checks for DT support from the driver.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 078e027386b2fdeb154393eb87a5b325d0937ed9)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra_alc5632: assume CONFIG_OF, and other cleanup

Tegra only supports, and always enables, device tree. Remove all runtime
checks for DT support from the driver.

Also, various minor cleanups so that the probe() body more closely
resembles other drivers, for easier comparison.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit f726536fc08db7a209e35b011883bbaee8e93db7)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra trimslice: assume CONFIG_OF, and other cleanup

Tegra only supports, and always enables, device tree. Remove all runtime
checks for DT support from the driver.

Also, some minor changes so that the probe() body more closely resembles
other drivers, for easier comparison.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit bd85a06c2b81d9947426d48125ee7a96a6c67e3c)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra_wm8903: assume CONFIG_OF, remove platform data

Tegra only supports, and always enables, device tree. Remove all runtime
checks for DT support from the driver.

This allows removal of the hard-coded Harmony ASoC mapping table, since
Harmony only boots with DT now.

All board-specific configuration now comes from device tree, so there is
no need to have a platform_data structure. Rework the driver to parse the
device tree directly into struct tegra_wm8903.

Also some slight re-ordering of probe() so that the code more closely
resembles other drivers for easier comparison. Inparticular, the GPIO DT
parsing and initial programming are moved together for each GPIO.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 8f5f5e0f459d37273f841e3f8da38b4e242c8e94)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra: fix I2S bit count mask

This register field is 11 bits wide, not 15 bits wide. Given the way
this value is currently, used, this patch has no practical effect.
However, it's still best if the value is correct.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 0af18c5cc9403999bb189f825b816f7fc80fc0ee)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: clk: Tegra: Remove duplicate smp_twd clock

Remove duplicate smp_twd clocks as these clocks are accessed using
DT now.

Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
(cherry picked from commit 984b839337da1eb7b4a4fb50e24cf28c2b473862)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: lib: devres: Introduce devm_ioremap_resource()

The devm_request_and_ioremap() function is very useful and helps avoid a
whole lot of boilerplate. However, one issue that keeps popping up is
its lack of a specific error code to determine which of the steps that
it performs failed. Furthermore, while the function gives an example and
suggests what error code to return on failure, a wide variety of error
codes are used throughout the tree.

In an attempt to fix these problems, this patch adds a new function that
drivers can transition to. The devm_ioremap_resource() returns a pointer
to the remapped I/O memory on success or an ERR_PTR() encoded error code
on failure. Callers can check for failure using IS_ERR() and determine
its cause by extracting the error code using PTR_ERR().

devm_request_and_ioremap() is implemented as a wrapper around the new
API and return NULL on failure as before. This ensures that backwards
compatibility is maintained until all users have been converted to the
new API, at which point the old devm_request_and_ioremap() function
should be removed.

A semantic patch is included which can be used to convert from the old
devm_request_and_ioremap() API to the new devm_ioremap_resource() API.
Some non-trivial cases may require manual intervention, though.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 75096579c3ac39ddc2f8b0d9a8924eba31f4d920)
Signed-off-by: Olof Johansson <olofj@chromium.org
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>
---
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?
Signed-off-by: Olof Johansson <olofj@chromium.org
CHROMIUM: ASoC: tegra: add tegra+RT5640 machine driver

FIXME: describe this

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra: add Tegra114 support to the AHUB driver

Tegra114's AHUB shares a design with Tegra30, with the followin changes:
* Supports more (10 vs. 4) bi-directional FIFO channels into RAM.
* Requires a separate block of registers to support the above.
* Supports more attached clients, i.e. new audio multiplexing and
  de-multiplexing modules.
* Is affected by more clocks due to the above.

This change fully defines the device tree binding changes required to
represent these changes, and minimally extends the driver to support
the new hardware, without exposing any of the new FIFO channels.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 95d36075694b0431da22c3aef3d0dccdcc781344)
(cherry-picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git topic/tegra)
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: ASoC: tegra: add Tegra114 support to tegra_asoc_utils.c

Tegra114 requires different PLL rates. Modify the code to know about
this.

On Tegra114 only for now, use regular clk_get() rather than clk_get_sys()
to retrieve clocks. This assumes that the clocks will be represented in
device tree. We can assure that from the start of any Tegra114 audio
support. For older chips, I'll add the required clocks properties to the
device trees this kernel cycle, and switch this code to only support the
"new_clocks" path next cycle.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit a7fc5d256be9fda27bb69e872e6a212542a84230)
(cherry-picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git topic/tegra)
Signed-off-by: Olof Johansson <olofj@chromium.org
CHROMIUM: ASoC: tegra: always use clk_get() in utility code

Now that all of the Tegra device trees have been updated to represent
the required audio clocks, remove the compatibility code from the Tegra
ASoC utility code, and always use clk_get() rather than clk_get_sys().

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
NOTE: This can't be applied until 3.11, due to a dependency on "ARM:
tegra: add clocks property to sound nodes" which went into 3.10.
Signed-off-by: Olof Johansson <olofj@chromium.org
UPSTREAM: power_supply: Add support for tps65090-charger

This patch adds support for the tps65090 charger driver. This driver is
responsible for controlling the charger aspect of the tps65090 mfd.
Currently, this mainly consists of turning on and off the charger, but
some features of the charger can be supported through this driver
including:

- Enable Auto Recharge based on Battery voltage
- Fast Charge Safety Timer
- Maximum battery discharge current
- Maximum battery adapter current
- Enable External Charge
- Disable charging termination based on low charger current (supported)

Once the driver is accepted, later patches can add support for the
features above which are not yet supported.

Based on work by:

  Syed Rafiuddin <srafiuddin@nvidia.com>
  Laxman Dewangan <ldewangan@nvidia.com>

Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
(cherry picked from commit 6f8da5df8c451103e0043f73a00c90676da6be9e)
(cherry-picked from git://git.infradead.org/battery-2.6.git)
UPSTREAM: tps65090: Setup compatible property for dt

Setup the compatible property so that when this device is registered
through device tree, it can match the expected compatiblity string used in
the tps65090 driver.

Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
(cherry picked from commit 594f8f888d325591851f419c22e0349263214eff)