msm: acpuclock-krait: Add a debugfs interface

Add a debugfs interface to peek at acpuclock driver state. Also
include support for enabled and disabling CPU and L2 hardware
clock gating, which is sometimes useful when performing clock
measurements.

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

Conflicts:
	arch/arm/mach-msm/acpuclock-krait.h
msm: acpuclock-krait: Support alternate PVS and speed bin format

msm8974 and future targets use a different eFuse register layout
than targets from previous SoC generations. Instead of hard-coding
acpuclock-krait to assume the old format, allow the format to
be decided on a per-SoC basis via function pointer assignments.

Two formats are currently supported:
 - "Format A", used for 8974
 - "Format B", used for older Krait-based targets

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

Conflicts:
	arch/arm/mach-msm/acpuclock-8064.c
msm: acpuclock-8960ab: Increase L2 frequency

Power testing has indicated benifits increasing L2 frequency from 702
to 810 MHZ.

Change-Id: I14aa892c3afd3d3dc7a32f1f6d51a4a872e1315a
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
msm: acpuclock-krait: Add support for HFPLL lock detect bit polling

Some recent devices have a lock detect bit that can be used to
determine when the HFPLL frequency has stabilized. Add optional
support for polling this bit instead of delaying pessimistically
for 60us.

Change-Id: I38bb0c98e36f66fc5efadf9189dbe817f648a972
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: acpuclock-krait: Add __init markings to 'krait vmin' functions

These functions are only called during boot and can be safely
discarded after.

Change-Id: I6bf20a42fec8b82c3f35e1c042b799ef2dad7790
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: acpuclock-krait: Remove inapplicable 8064 errata workaround

The secondary MUX switching errata is worked around in the secure
warm-boot path, and does not require an in-kernel workaround.

For devices with older warm-boot code (without the workaround),
the removal of the kernel workaround is also safe. The errata
symptoms can only manifest themselves after an L2 power-collapse,
which can't occur until after all Krait CPUs have been brought
online at least once. Since the secondary MUX is only touched by
acpuclock when onlining CPUs for the first time, the MUX will
never be switched after L2 power-collapse.

Change-Id: If675cfab7f325a9f7af6e06ff5ed67bd65461f20
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: acpuclock-krait: Only print supported number of frequencies once

The current code prints the number of CPU frequencies supported
once for each possible CPU, even though the number of supported
frequencies is the same for each CPU. Cut down on log noise by
printing this number only once.

For example, print:

  [ 0.412932] acpuclk-8974 qcom,acpuclk.23: CPU Frequencies Supported: 11

...instead of:

  [ 0.426013] acpuclk-8974 qcom,acpuclk.23: CPU0: 11 frequencies supported
  [ 0.426052] acpuclk-8974 qcom,acpuclk.23: CPU1: 11 frequencies supported
  [ 0.426089] acpuclk-8974 qcom,acpuclk.23: CPU2: 11 frequencies supported
  [ 0.426124] acpuclk-8974 qcom,acpuclk.23: CPU3: 11 frequencies supported

Change-Id: Iaf15970e6cfcfaec79c0edf8564cab9141fbc05f
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: saw-regulator: Support enable and disable

Enable and disable callbacks are added as an optimization so that
we don't update voltages when the regulator is disabled. The use
case for this is a call sequence during CPU Hotplug like so:

Down:

regulator_disable()
regulator_set_voltage(0)

Up:

regulator_set_voltage(original_voltage)
regulator_enable()

Since the SPM actually enables and disables the regulator when
executing a WFI, we want these calls to actually amount to NOPs.
The calls must exist for consistency with other regulator
implementations that do mandate this sequence.

In order to support this sequence, regulator_disable() will simply
set the device to 'offline'. When a regulator is offline, then
calls to regulator_set_voltage() do not actually adjust the
voltage through the SPM; they simply cache the value that was
specified. Then, during regulator_enable, iff the voltage value
corresponding to the last regulator_set_voltage differs from the
value actually programmed in hardware do we reprogram the
hardware.

These rules support the call sequence above since the last value
written to hardware will occur with the regulator enabled by
acpuclock. When executing Hotplug Down, the
set_voltage(0) call does not take effect since the regulator has
been explicitly disabled. In the Hotplug Up case, the set_voltage
case is also cached since the regulator remains disabled. The
value set by the client here should be equal to the value
previously set in hardware (eg. restore). Lastly, the
regulaor_enable() callback sees that the value are the same, and
therefore does not update hardware.

Change-Id: I071a25e6d0c30e378c5dcddcdd9ae26fe02da04a
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/asustek/flo/board-flo-regulator.c
msm: acpuclock-krait: Use standard regulator APIs during CPU Hotplug

Voltage regulators supplying CPU cores need to be properly
notified when their underlying core goes offline. Use
regulator_disable() / regulator_enable() during this case to
notify them. Also make calls to regulator_set_voltage to
complement the regulator_disable call, since in the regulator
framework voltages are orthogonal to enable / disable.

This solves a problem on msm8974 where the ganged regulator
voltage is left higher than necessary when offlining CPU cores.

CRs-fixed: 410992
Change-Id: I1e569924133d98e75343d8b4ff24901dd2951de7
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
msm: spm-v2: Add API to enable PFM mode on PMIC

When the Kraits are drawing the least power, the Krait buck can be put
in low power mode (PFM) as well.
The msm_spm_enable_fts_lpm() API will allow the PFM mode to be enabled
through the SPM PMIC interface.

Change-Id: Ia5fd16e27e2c90683f6ae93b1e909fa79722a091
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
msm: spm-v2: NULL check for dev pointer

Make sure dev pointer is not NULL before accessing it.

Change-Id: I1808d166c1eefd4f17be13d5252c0fcd0ec86c80
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
msm: spm-v2: Store voltage levels into PMIC_DATA3

On certain targets, where the SPM controls the power supply for each
core, the SPM power down sequence takes care of restoring the Voltage
level after a power collapse to the appropriate sleep level. The active
voltage level is stored in the PMIC_DATA_3 register and SPM state
machine uses the data in this register to restore the voltage to the
current active level.

Change-Id: I4a25440e818abdefec8cdfd3491fe9a7d772aab4
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: cache_erp: Handle recoverable L1 errors

Some CPU designs may be able to recover from certain types
of L1 instruction cache errors. Rather than panicing
whenever any kind of L1 error is encountered, add an option
to selectively panic on recoverable L1 errors.

Change-Id: Id8beb0e58d41fa5319f4ca76c5f35e2162f8b704
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm: cache_erp: Dump I/O regions on cache errors

Support dumping arbitrary I/O register regions in response
to soft cache errors to facilitate identifying the cause of
the soft errors.

Change-Id: I4ccb720faecb0c7c1227e37234b9310a3d34f215
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
cache_erp: Use seq_printf and modernize procfs code

In future kernels create_proc_entry() is going to be removed.
Let's modernize this code and use regular file operations and
seq_printf() to avoid experiencing compilation problems in future
kernels.

Change-Id: Ifc11287a8aefa8b2af3fb7d68fd96c1db8f2f098
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: spm: Add msm_spm_get_vdd() API for SAW v1 driver

Add msm_spm_get_vdd() API to return the core active voltage. This change
was added for SAW v2 driver, making this change for SAW v1 driver also.

Change-Id: If870bf26c24806ecf3f2102ec586f93eac8071d7
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
msm: spm: Conform comments to coding standards

Move function header comments to the implementation from the header
file.

Change-Id: Idc09f746ae01b1117012c9a442aca3bd412f28aa
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
msm: spm_devices: Update notify_rpm flag for L2 retention

The L2 retention sequence doesn't have a sequence to notify RPM. Update
the notify_rpm flag in the L2 modes table to match the SPM command
sequence.

Change-Id: I12034ee3565fffa40f8a9b4e2e1aac28f3d538af
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: spm_devices: Disable SPM APIs when device isn't registered

If the SPM device isn't registered, then the SPM APIs should fail
returning proper error conditions. Failure to do so could cause data
abort when device writes to a memory address that isn't initialized.

Change-Id: I3903bf40491d1f51a3578f9ae950a992060ab121
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: spm_devices: Initialize return error code

If msm_spm_set_vdd() is called when a driver is uninitialized, then the
function returns an uninitialized error code to the caller. Fix by
initializing the error code to -ENODEV.

Change-Id: I0da7c1459757158c69eddff58188b0b5859df17e
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>