acpuclock:  remove unused code and added a few more steps

Change-Id: Ia1434536532ac736e8f0b5295e0a94b4651f2148
tracing/sched: Add trace events to track cpu hotplug.

Add ftrace event trace_sched_cpu_hotplug to track cpu
hot-add and hot-remove events.

This is useful in a variety of power, performance and
debug analysis scenarios.

Change-Id: I5d202c7a229ffacc3aafb7cf9afee0b0ee7b0931
Signed-off-by: Arun Bharadwaj <abharadw@codeaurora.org>
PM / QoS: Fix deadlock during PM QoS vote to default value

pm_qos_work_fn() calls pm_qos_update_request() which does
cancel_delayed_work_sync() on the same pm_qos_work_fn()
causing deadlock. Fix this by updating the target with
default timeout value directly instead of calling
pm_qos_update_request().

CRs-Fixed: 526216
Change-Id: I7de2fb1c89f87b0ebf7427116b8920aec50d5b2b
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
msm: pm-8x60: Modify L2 management mechanism in power collapse

Modify the L2 cache flush mechanism during Power collapse. For targets
with external L2 and TZ, L2 can only be flushed and not disabled as this
a secure operation. For targets with external L2 and no TZ kernel can flush
and disable the L2 cache. The decision on which cache flush mechanism to
use is determined by the power collapse type being exercised on that
platform.
Also modify the usage of qtimer based on target specific configuration
instead of using a socinfo based API to determine CPU type.

Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
Change-Id: Ib937c15782760cb81e19ac7093cb1c4fffd36afd
msm: idle: 8x60 doesn't seem to like CMD_TERMINATE_PC to go into deep idle.
ARM: cache_l2x0: Set outer_cache resume

Set the outer_cache.resume function during l2x0_init and declare a static
inline void version to allow compilation when OUTER_CACHE is not defined.
The outer_cache functions are used for L2 cache management in chips that
have an external cache controller. The outer_cache.resume re-enables the
L2 cache controller and is called when exiting power collapse.
This change is needed to allow drivers to call outer_cache API's instead
of directly using the APIs defined in cache-l2x0.c and thus avoid having
to use #ifdef macros in the code.

Change-Id: Ifc7d25f905e3248f864c9eaf019436968e77b8a2
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
tenderloin: Bump up Min Volt to match 2.6 kernel

Change-Id: I37771680805792dcbd9de1e652d8c73fbbf4a97a
msm: pm-8x60: Use ktime_get for suspend stats

During suspend, the sched clock is stopped and the suspends ops
cannot rely on sched clock to report time spent in suspend. Use ktime
interface to determine the time spent in suspend.

Change-Id: Id244cd8d470c45c1edd408e98ccaf84d30c3e253
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Don't save or restore GIC,VFP state in power collapse

Don't save or restore the GIC,VFP registers when entering or exiting power
collapse. The GIC and VFP drivers already register for PM notifications and
do the respective save/restore thereby making these operations redundant in
pm-8x60 driver.

Change-Id: If9969f8052843b2c7c1417dfeceaab203c6453b5
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
msm: tracing: Add ftrace support for LPM driver

Add trace event support to capture various parameters
of low power modes like power collapse, standalone power
collapse, retention and wfi during its entry and exit.

Change-Id: I0f8b918702ae47b354aa193aa7ef20b48110fb0f
Signed-off-by: Priyanka Mathur <pmathur@codeaurora.org>
msm: pm: Add API to enable/disable retention mode

On 8974 targets, retention mode voltage is controlled by the LDO
regulator, which in turn is powered through a ganged PMIC regulators. At
certain low voltage levels, the ganged PMIC will not be able to power
the LDO retention voltage. The regulator framework would invoke this
API to enable/disable retention mode in these scenarios.

When disabling retention modes, send a IPI to wakeup all online cores
out of idle, to ensure that no core is in a retention low power mode.
Also, disabled support for retention during suspend/hotplug operations
to ensure that a CPU isn't already in retention when the voltage is
lowered. This shouldn't have an effect on suspend, as the driver always
chooses the deepest sleep mode for suspend/hotplug.

Change-Id: I0af18168968c2aaf05ca99188d30762612c87de6
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Overhaul the low power management driver

Overhaul the pm-8x60 driver code to remove the target specific runtime
state machine variables out of the driver code into its own board
specific files.

IMEM debug PC counters specified by debug-pc-cntr used to have its own
binding. Now that pm-8x60 has other bindings, use pm-8x60 device tree
bindings to handle debug PC counters.

Change-Id: I4f16008098c9525d3543ba23a5f58ddc3a8f942d
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Support to do PC at the running core frequency

New version of SAW2 (>v2.1), support turning off/on HFPLL only if the
PLL was active when entering power collapse. This eliminates the need
to switch to a lower frequency running off global PLL, and then turn
off the HFPLL. Power collapse with RPM notification should be a tad
bit faster.

Change-Id: I65c607454bd6c9a6b6da94e3946760e581ac761b
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Fix bug where CPU doesn't enter PC

When Krait regulator disables retention mode, an incorrect ordering of
the switch case disables power collapse.

Change-Id: Ic58b0356530e9ecb10d379e2f99d14016bc251e4
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Debugfs node to read PC warmboot counters

Add debugfs to read warmboot counters from IMEM memory.

Sample output is as follows.
cat /sys/kernel/debug/pc_debug_counter
CPU0
        PC Entry Counter : 378
        Warmboot Entry Counter : 370
        PC Bailout Counter : 8
CPU1
        PC Entry Counter : 10
        Warmboot Entry Counter : 10
        PC Bailout Counter : 0
CPU2
        PC Entry Counter : 6
        Warmboot Entry Counter : 6
        PC Bailout Counter : 0
CPU3
        PC Entry Counter : 2
        Warmboot Entry Counter : 2
        PC Bailout Counter : 0

Change-Id: I245c80b88fee9bd6bef89fdcb4d0721622bd4d28
Signed-off-by: Priyanka Mathur <pmathur@codeaurora.org>
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Merge msm_pm_idle_prepare into msm_pm_idle_enter

Modify LPM drivers to call msm_pm_idle_enter when idle. enter_sleep will
look at available time to sleep and the latencies of different low power
modes and decide the low power mode to enter. It returns the low power
mode enumeration back to cpuidle.

Change-Id: I56717f2ba7a748b38d53b418381a01159055e7bd
Signed-off-by: Priyanka Mathur <pmathur@codeaurora.org>
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Remove enum from devicetree

Replace enums with strings in Device tree for pc-mode

Change-Id: If63212e07e42f7b0b9d4dd046ae52f0349901154
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Revert "msm: pm-8x60: Use ktime_get for suspend stats"

This reverts commit 0664ee443041626fc7f7811616012444f6b20261. On 3.7
kernel, the sched_clock is stopped during suspend/resume and was
reporting time in suspend as zero. On 3.4 kernel, ktime_get() throws a
warning when invoked from suspend ops.

Change-Id: Id989da42a1c2600f9c09c527ffff7a8a1ac52090
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Disable premption in msm_pm_enable_retention

msm_pm_retention_enable() makes smp_call_function_many to ensure that
when a retention is disabled, the cores come out of its low power mode.
Per the smp_call_function_many documentations, preemption should be
disabled before invoking the API.

CRs-fixed: 463188
Change-Id: I4ae9137e8f8e821af729becd0e2d6e6886d5e787
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Add early return to msm_pm_enable_retention()

If retention is already disabled, it is not necessary to send IPIs to
the running CPUs to wake them up. Insert an early return for this
scenario to reduce overhead during Krait rail voltage scaling, which
calls this API on every voltage change.

Change-Id: I5db0bafae187ff8a68488e86d4787df9c45787e4
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>