OMAP4: DSP: Use software control for clockdomain

Hardware control (HWSUP) for DSP clock domain doesn't seem to work
correctly resulting in a bunch of L3 bus errors when bringing up DSP.
We resort to Software control (SWSUP) to fix this issue.

e.g. of L3 bus errors without this patch

[   33.025390] rproc remoteproc0: powering up dsp_c0
[   33.047271] rproc remoteproc0: Booting fw image tesla-dsp.xe64T, size 874888
[   33.075408] omap_hwmod: dsp: failed to hardreset
[   33.080383] omap-iommu omap-iommu.0: dsp: version 2.0
[   33.115203] rproc remoteproc0: remote processor dsp_c0 is now up
[   33.126312] virtio_rpmsg_bus virtio0: rpmsg host is online
[   33.132415] rproc remoteproc0: registered virtio0 (type 7)
[   33.154235] omap-rproc omap-rproc.0: received echo reply from dsp_c0
[   33.160980] ------------[ cut here ]------------
[   33.165893] WARNING: at arch/arm/mach-omap2/omap_l3_noc.c:117 l3_interrupt_handler+0x140/0x18c()
[   33.175170] L3 custom error: MASTER:DSP TARGET:GPMC

Signed-off-by: Roger Quadros <rogerq@ti.com>
gpio/omap: Fix context lost issue with OFF mode

Fixes power up issue with TWL6040 audio codec and
WLAN SDIO not found errors while resuming from OFF mode.

Signed-off-by: Roger Quadros <rogerq@ti.com>
gpio/omap: fix invalid context restore of gpio bank-0

Currently the gpio _runtime_resume/suspend functions are calling the
get_context_loss_count() platform function if the function is populated for
a gpio bank. This function is used to determine if the gpio bank logic state
needs to be restored due to a power transition. This function will be populated
for all banks, but it should only be called for banks that have the
"loses_context" variable set. It is pointless to call this if loses_context is
false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will
never lose context. We found that the get_context_loss_count() was being called
for bank-0 during the probe and returning 1 instead of 0 indicating that the
context had been lost. This was causing the context restore function to be
called at probe time for this bank and because the context had never been saved,
was restoring an invalid state. This ultimately resulted in a crash [1].

This issue is a regression that was exposed by commit 1b1287032 (gpio/omap: fix
missing check in *_runtime_suspend()).

There are multiple bugs here that need to be addressed ...

1. Why the always-on power domain returns a context loss count of 1? This needs
   to be fixed in the power domain code [2]. However, the gpio driver should not
   assume the loss count is 0 to begin with.
2. The omap gpio driver should never be calling get_context_loss_count for a
   gpio bank in a always-on domain. This is pointless and adds unneccessary
   overhead.
3. The OMAP gpio driver assumes that the initial power domain context loss count
   will be 0 at the time the gpio driver is probed. However, it could be
   possible that this is not the case and an invalid context restore could be
   performed during the probe. To avoid this only populate the
   get_context_loss_count() function pointer after the initial call to
   pm_runtime_get() has occurred. This will ensure that the first
   pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.

[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2
[2] http://marc.info/?l=linux-omap&m=134100413303810&w=2

Cc: Kevin Hilman <khilman@ti.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Franky Lin <frankyl@broadcom.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: NeilBrown <neilb@suse.de>

Reported-by: Franky Lin <frankyl@broadcom.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Franky Lin <frankyl@broadcom.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: NeilBrown <neilb@suse.de>
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
ARM PMD disallow half-written entries crashing things

On ARM with the 2-level page table format, a PMD entry is represented by
two consecutive section entries covering 2MB of virtual space.

However, static mappings always were allowed to use separate 1MB section
entries.  This means in practice that a static mapping may create half
populated PMDs via create_mapping().

Since commit 0536bdf33f (ARM: move iotable mappings within the vmalloc
region) those static mappings are located in the vmalloc area. We must
ensure no such half populated PMDs are accessible once vmalloc() or
ioremap() start looking at the vmalloc area for nearby free virtual
address ranges, or various things leading to a kernel crash will happen.

Signed-off-by: Nicolas Pitre <npitre@linaro.org>
Reported-by: Santosh Shilimkar
Tested-by: R, Sricharan
Reviewed-by: Catalin Marinas
Cc: stable@vger.kernel.org
omap: fix SmartReflex 1.5 compilation

Signed-off-by: Sebastien Jan <s-jan@ti.com>
OMAP3630+: SmartReflex: Ensure worker canceled prior to free

sr_class1p5_disable may fail to cancel the worker if
omap_voltage_get_curr_vdata() returns NULL, as during
reboot.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Sebastien Jan <s-jan@ti.com>
OMAP2+: PM: Voltage: allow software margin per OPP

Allow per OPP software margin to be defined in OPP table
for the voltage definitions.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Sebastien Jan <s-jan@ti.com>
OMAP3630+: SmartReflex: use margins per volt_data

Instead of using a generic margin for all volt_data instances
use customized margin per OPP's volt_data instance.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Sebastien Jan <s-jan@ti.com>
OMAP4460: OPP: SR1.5: update margin to spec rev 0.5

Update SR1.5 voltage margin from Operating Conditions Data Manual
Addendum Revision 0.5 (March 2012) for OMAP4460.

Signed-off-by: Sebastien Jan <s-jan@ti.com>
omap: SmartReflex: add synchro with DVFS

Signed-off-by: Sebastien Jan <s-jan@ti.com>
omap: improve SmartReflex non-converged behavior

In case SR does not converge, rather than using the nominal voltage,
use the highest value among the last 5 measures done.

Code grabbed from TI Android 3.0 kernel.

Tested the oscillating code by hacking the do_calibrate function, but
not able to put SR in an oscillating case, and no SR interrupts triggered
appart from one at init while interrupts are masked. So not sure if this
code is really useful, but at least is shall not be harmful :).

Signed-off-by: Sebastien Jan <s-jan@ti.com>
Config: enable SmartReflex class 1.5

Signed-off-by: Sebastien Jan <s-jan@ti.com>
revert sr 1.5 for now

Signed-off-by: Andy Green <andy.green@linaro.org>
OMAP: HSMMC: Revert "OMAP HSMMC Force enable attempt so that we can call disable"

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
OMAP: HSMMC: Track regulator enabled locally

The regulator api doesn't differentiate between a real and a dummy reg.
The latter is always reported enabled, the local flag 'regulator_enabled'
tracks if the driver explicitly enabled the regulator, otherwise we get
imbalance in calls to enable/disable when its a dummy regulator.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
OMAP2: DSS: Use msleep instead of blocking mdelay

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
hdmi: set default resolution to 1024x768

The PLL sometimes fails to lock on low resolutions (like 640x480).
Using 1024x768 avoids this problem and permits to continue the
init path until EDID reading and optimized resolution choice.

Signed-off-by: Sebastien Jan <s-jan@ti.com>
OMAP3+: pm-debug: expose wakeup_timer_seconds in debugfs

We will need this for OFF mode testing.

Signed-off-by: Roger Quadros <rogerq@ti.com>
usb: musb: Save controller state during system suspend

Without this the controller will not work after a system
suspend/resume with OFF mode enabled.

Signed-off-by: Roger Quadros <rogerq@ti.com>