idle2: v0.382 standalone patch by thalamus
idle2: v0.383
Add functionality which allows IDLE2 to be killed temporarily from a call.
This is currently implemented to disable IDLE2 when the system is
suspending and it is also being used to work around a bug which occurs
when the modem crashes whilst IDLE2 is enabled (see comment in modem_ctl.c).

Also, go back to the pre v0.382 method of detecting earlysuspend.
The notifier is too slow and causes problems with ANRs in systemui in rare
circumstances. Thanks to morfic for the heads up.
idle2: v0.390
Hopefully fix bluetooth streaming / tethering issue by rewriting bluetooth
activity detection code. Also rewrite the UART detection code and remove
the complicated idle2_cancel_topon_work_fn() as it's all rewritten to be much
simpler by separating out the two requests. The UART code has been simplified
the delayed work has been removed and it is a simple toggle now to set a flag.

The bluetooth detection has been rewritten as a oneshot function which is
fired every time the bluetooth host wake IRQ handler is invoked and disables
TOP block off for 10 seconds each time it is fired.
If bluetooth streaming is active, this will be fired regularly, causing the
SoC to stay in TOP block on mode and allow the music to continue.

Flush caches after waking to ensure they are clear

IDLE2 will now only be active when the screen is off. This should work
around any reported performance issues. The actual benefit of IDLE2 whilst
the screen is on is pretty much nil anyway.

Optimise code for TOP block off fast path.

Use cancel_delayed_work() instead of cancel_delayed_work_sync() as we are
atomic and cancel_delayed_work_sync() might_sleep() which causes a BUG().

Net deletion of 56 lines of code, so some of the bloat is going. :p
cpuidle: idle2: v0.391
Increase Bluetooth timeout to 60 secs - still getting rare reports of
audio streams dying when screen off, this should resolve it.

Add notifiers for timer infrastructure and add CPU PM notifier, which
currently saves the vfp state before entering into IDLE2.
Depends on: 0f9694f and 0ed40c6 (the 2 commits before this).
idle2: Align entry code with PM code
Enable idle2
ARM: vfp: Use cpu pm notifiers to save vfp state

When the cpu is powered down in a low power mode, the vfp
registers may be reset.

This patch uses CPU_PM_ENTER and CPU_PM_EXIT notifiers to save
and restore the cpu's vfp registers.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
Tested-and-Acked-by: Shawn Guo <shawn.guo@linaro.org>
Tested-by: Vishwanath BS <vishwanath.bs@ti.com>
cpu_pm: Add cpu power management notifiers

During some CPU power modes entered during idle, hotplug and
suspend, peripherals located in the CPU power domain, such as
the GIC, localtimers, and VFP, may be powered down.  Add a
notifier chain that allows drivers for those peripherals to
be notified before and after they may be reset.

Notified drivers can include VFP co-processor, interrupt controller
and it's PM extensions, local CPU timers context save/restore which
shouldn't be interrupted. Hence CPU PM event APIs  must be called
with interrupts disabled.

Change-Id: Id7913c16c538eb59b30a33ef6efeb35e57c94d05
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
Tested-and-Acked-by: Shawn Guo <shawn.guo@linaro.org>
Tested-by: Kevin Hilman <khilman@ti.com>
Tested-by: Vishwanath BS <vishwanath.bs@ti.com>