Revert "msm: lpm_resources: Ignore RPM notifications only during RPM PC."

This reverts commit 06b0425ff9f6962d176d5c9054b8d364cd282630.

Signed-off-by: flar2 <asegaert@gmail.com>
msm: pm-8x60: Register sleep status driver before regulator

During hotplug, drivers wait for core to be power collapsed to turn off
the resources used by a core in CPU_DEAD notification. The kernel
thermal module which hotplugs the core in certain conditions is
registered in the arch_initcall(). To ensure that the CPU_DEAD waits for
sleep status to be set during hotplug, register the cpu sleep status
driver before the regulator driver.

To this effect, the sleep status driver is no longer made a child device
for pm-8x60 device.

Change-Id: I772521f4b3cd18e367aa44a41d60ef9735c99ef9
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: lpm: Alter the voting mechanism for lpm drivers

Currently the power management drivers monitor the sleep votes received
for certain system wide resources such as system clock and digital voltage
rail. By knowing the sleep vote and the available sleep time , latency
requests the low power management drivers (lpm_resources module) can alter
the sleep votes for those resources during RPM notified sleep modes.

Changing this method because this method requires a new low power level be
added for each combination of the system wide resources being monitored
and that each level be characterized (latency, power etc), this method is
not very scalable as the number of system resources being monitored by the
low power management driver increases. But most of all the decisions on
whether there is enough sleep time to enter these system wide sleep modes
(residency decisions) need to be made at RPM.

This change will remove the lpm_resources module altogether and remove all
low power levels beyond those pertaining L2 cache at lpm_levels.

CRs-Fixed: 490824
Change-Id: I255b696851074dcf7bed40b648c0eb3c5c4d0d6d
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: lpm_levels: Adjust latency for Multi core cases

In multi core cases for several cores going in and out of power collapse
the warmboot is serialized at Trust Zone, which means the exit latency
will scale based on the number of cores exiting power collapse.

Adjust for this when chosing a low power mode based on the number of online
cpus.

Change-Id: I4fe137a1bf8596b7da7990845b18ceb8f3d529da
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: clock: Keep proper track of current voltage level

Fix a bug where vdd_class->cur_level is not updated when regulator api
calls are successful. The impact of the bug is unnecessary calls to
regulator APIs but not additional RPM calls since the regulator APIs
will optimize out repeated requests for the same voltage/current.

In case the regulator APIs fail, this bug might also result in
undervolting. But that's an unlikely case in a real product.

Change-Id: Ibe3574b6b72fcf898a5bfe9b5b253a8d0e0125ae
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
hammerhead: Updates for recent PM changes

Change-Id: I94ebd3376c990879cd6ca0a140ff8c102b567acb

Signed-off-by: flar2 <asegaert@gmail.com>
msm: spm: Replace msm_spm_apcs_set_vdd with msm_spm_set_vdd

msm_spm_apcs_set_vdd() is used to set the vdd of a gang rail through the
L2 SAW2. Remove this api and overload the msm_spm_set_vdd() call with a
dont-care 'cpu' argument instead.

Detect if the target is configured to use L2 SAW as APCS master using a
boolean property in the device tree.

Change-Id: Ib8d9605474fa44d5223985ec8cb1040cde230592
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: rpm-master-stat: Modify RPM master stats platform data

Currently each master stats are placed in RPM message
RAM at a fixed offset location. This can be varied across
different platforms. Hence adding  a 'master_offset'
variable to platform data. This avoids the hard coding
of offset value in rpm master stats driver.

CRs-Fixed: 517589
Change-Id: Ifb89b518930022a735495622712f694a987f47f3
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: rpm_master_stats: Add DT support for rpm master stat driver

RPM master stats driver is used to show each master stats by
reading the RPM message RAM. These stats shows the useful
information of each subsystems like "active cores", "number of
shoutdowns" and "wakeup reason" etc. Current driver do not have
the DT support and it can't be used for few targets. Hence
implementing the DT support and make the driver more generic to
support different family of chipsets.

CRs-Fixed: 517589
Change-Id: If6695939c6da5e0620f91f21a8b377be12ccb444
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: spm-regulator: add support for mode selection

Add support to the spm-regulator driver to select which regulator
operating mode to utilize.  There are three possible mode
selections: PWM mode, auto mode, or the existing mode set by
hardware or bootloaders.

Change-Id: Ieaf69f26078d4e9f14db3b2eb7b5cbe2dc8ed31e
Signed-off-by: David Collins <collinsd@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: spm: add intermediate LPM mode for L2 PC

Currently when the core decide to enter into "PC + L2 PC"
LPM mode it informs to RPM and there is a chance of
system can enter into either XO or VDDmin. But this LPM
mode take longer time to enter and exit. Because of this
limitation some of the usecases where there is a less
latency APPS proc stays at lower LPM level (i.e GDFS) and
causing more power consumption. To address this issue adding
an intermediate LPM mode where L2 goes to PC but not inform
to RPM.

CRs-fixed: 552743
Change-Id: I321ff260d5baf8ac44917d67e9c9dfd260c8d5ca
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: krait-regulator: force BHS on offlined CPUs at boot

There could be regulator enable calls on offlined CPUs at boot time.
That leads to an issue where the driver calls smp functions on them
to switch ldo/bhs.

Set the force_bhs flags on offlined CPUs at boot to avoid this problem.

Change-Id: I9f5bccc89e59ef2da12670b921b98e02fb078acf
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: krait-regulator: Add flag to disable LDO mode usage

Add a feature which allows to disable using LDO. When enabled, the
core continues to run from BHS possibly seeing a higher input voltage.
This may increase the leakage from the core but will not cause a
brownout.

Change-Id: I793af7a9eeddfd52f5fea9b4c59c774f0272f431
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: krait-regulator: fix the cold boot sequence

One has to turn on BHS regardless of the kpss version. This gets
us to the expected APC_PWR_GATE_CONFIG register prior to enabling
sequencer.

Change-Id: I6c44f3e70b56211dae682c3b2740519f22f53f94
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: rpm-regulator-smd: correct use-after-free in rpm_vreg_device_remove

Modify the rpm_vreg_device_remove() function so that the reg
pointer is not dereferenced after being freed.

Change-Id: I0bc2c38a00c5d6b783f52c0ae0f1faa31d3a1e4d
CRs-Fixed: 564463
Signed-off-by: David Collins <collinsd@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: idle-v7: Add support to pass tz flag when core is hotplugged

When a core is hotplugged, trustzone migrates secure SPI to
the core that is online. Pass a flag to TZ indicating if it is
hotplugged or not.

Change-Id: I38d5a1987cdde9c6f3a456b7bb7726289ab0ad81
Signed-off-by: Priyanka Mathur <pmathur@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>

Conflicts:
	arch/arm/mach-msm/idle-v7.S
msm: rpm_stats: show master votes for xo/cxo sleep mode

RPM sleep stats structure has "client_votes" field. It
provides the information of masters who is preventing
the RPM from entering the associated sleep mode(xo/cxo).
Print client_votes info along with xo & vddmin stats.

CRs-fixed: 576283
Change-Id: Ia656add1b8ade7a92502058b8eb6a22516990b7a
Signed-off-by: Harry Yang <harryy@codeaurora.org>
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: rpm-regulator-smd: limit current to RPM defined maximum

Modify the rpm_vreg_get_optimum_mode() function so that it
restricts the maximum current that can be sent for the 'ma' KVP
to the limit defined by the RPM.

Change-Id: I744e656c75a5e78a81df9c283a8f14a977c4c6ee
Signed-off-by: David Collins <collinsd@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: rpm-regulator-smd: remove incorrect rpm_regulator_get() unlock calls

The rpm_regulator_get() function calls rpm_vreg_unlock() in
failure paths after two kzalloc() calls.  However, there is no
corresponding rpm_vreg_lock() call before these calls.  Also, the
code being executed does not require mutual exclusion.  Thus,
remove the rpm_vreg_unlock() calls in order to avoid possible
locking problems if kzalloc() fails.

Change-Id: I0a0f2ffde5a6c54600a823e3ed12c3c47c3bac6a
Signed-off-by: David Collins <collinsd@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>
msm: sps: free the interrupt for satellite mode

When BAM is registered in satellite mode on apps side, we do not
need to disable BAM HW when apps side does not use that BAM any
more. But we still should free the interrupt. This is addressed
in this change.

Change-Id: I955ea1a341036efa82f0ecc0f45cad5ec41651ae
Signed-off-by: Yan He <yanhe@codeaurora.org>
Signed-off-by: flar2 <asegaert@gmail.com>