Revert "Revert "msm: pm-8x60: Don't save or restore GIC,VFP state in power collapse""

This reverts commit 0eafe608e38a6a87183f5e40d93ae3195e4951a6.
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>
Hammerhead: Register sleep status driver before regulator
msm: pm-8x60: Increase warn timeout for sleep sts check

Arm cores take longer time to enter sleep. Wait for longer
time before warning until the CPU goes to sleep state.

Change-Id: I15caa8b2b2560aa68a4f4967c3364533234584b7
Signed-off-by: Priyanka Mathur <pmathur@codeaurora.org>
msm: idle-v7: Separate PC termination for hotplug

When a core is power collapsed as a part of hotplug the state of the CPU
isn't restored and hence there isn't a need to save the registers. This
change is needed by a subsequent patch that will reserve a DMA memory to
save the register contents. The DMA memory region isn't available until
arch initcall and the kernel thermal module could hotplug a core for
thermal considerations.

CRs-fixed: 489391
Change-Id: Idf6ec5212482ccff91500edc4988516389189627
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Use dma_alloc_coherent for the saved region

dma_alloc_coherent is the linux standard way of allocating coherent
(i.e. uncached) memory. This API provides more guarantess than the
custom allocate_contiguous_ebi function, including the ability to
specify allocations from the lower 4G of memory. Switch to this API
for allocation of uncached memory. Because using dma_alloc_coherent
may have other setup involved, switch the setup function to be a
later initcall as well (from core_initcall to arch_initcall).

Change-Id: I96ea4575e5ee82ccbf7e691ba75ea1414dc6d81a
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: pm-8x60: Update the identity mapping for LPAE

The pm code uses a known stable page table with an identity mapping
for coming in and out of power collapse. This table currently assumes
a standard two level page table. This is incompatible with the new
format for LPAE. Update the code to handle both the LPAE and non-LPAE
page tables for power collapse.

Change-Id: I58097744134207fac49d7ab2147ba34f2f244a94
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Revert "msm: pm-8x60: Add PNOC request to prevent PNOC clk gating"

This reverts commit 9b186afca6c206ef1e74c138a10b75bdab4ba422.

Change-Id: Ifb0e0af69f6e63cae74ba2c50cb5d126257bc43d
Signed-off-by: Badhri Jagan Sridharan <badhris@codeaurora.org>
msm:pm-8x60: Do not generate access flag faults for the kernel mappings

The pgd mapping (msm_pm_pc_pgd) generates Access flag fault whenever
this entry is read into the TLB for the first time. Add this flag to
the pgd mapping such that when the fault occurs, software resets the
Access flag to 1 in the translation table entry that caused the fault.
This prevents the fault from occurring the next time that memory
location is accessed.

Change-Id: I8d2ecc4d4005955ddeeaf3953ca1c445163b694c
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
msm: mpm: Use clock API to prevent XO shutdown

When the active interrupts cannot be monitored by MPM during system
sleep modes, use linux clock APIs to vote against XO shutdown. Earlier
mpm driver relies on lpm resoures to overwrite the clock votes based on
enabled interrupts. This change decouples the MPM driver from the
lpm resources and thereby removing the dependency on RPM driver.

Change-Id: Ica5409ebb6744998303d84867f9b6d0243664b7e
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm-8x60: Fix suspend time tracking

Calls to sched_clock() after syscore devices have been suspend
will return the same value until the syscored devices are
resumed. Furthermore, the value won't jump forward to account for
the time left in suspend so we can't use it to calculate how much
time we spent in suspend.

We could expose the hardware directly to the pm code but it's
better to use generic interfaces. Move to using the timekeeping
APIs to determine how long we were in suspend. Unfortunately, we
can't use the timekeeping APIs this early in the resume path, so
we must read the current time of day before we suspend the
timekeeping core and after we resume the timekeeping core. Move
the calls to the suspend_late() and wake() callbacks so we can
properly read the amount of suspend time.

CRs-fixed: 536881
Change-Id: I3b47511afb75926e51e82fc83929f405404fbf07
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Revert "msm: pm-8x60: Don't save or restore GIC,VFP state in power collapse"

Save and restore of GIC and VFP state is required to avoid subtle
userspace crashes due to corrupted state across power-collapse

This reverts commit a291d8a5596ba23ed3c03629ae50169443dd6159.

CRs-Fixed: 550405
Change-Id: I1ebe5666dc858116ddc5b830d706e3dacbb16cbe
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
ARM: abort: don't clear the exclusive monitors
ARM: errata: work around Cortex-A15 erratum 830321 using dummy strex