msm: Add krait scm driver to configure cpu

Provide sysfs access for user space to query and control krait
processor-internal settings via the secure monitor interface.

Change-Id: Id1c00596e65794267643dc7fa1f3155278e34571
Signed-off-by: Trevor Bourget <tbourget@codeaurora.org>
msm: memory: Use standard cache routines

Convert custom clean, flush, and invalidate cache routines to use
standard ARM cache routines.

Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 29bb4d5fa7a285c8fb5d5db55225dab700b80419)

Change-Id: I2c83c27e55811a42fdfdbca08c3db772c5c83e15
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: krait-l2-accessor: Add missing barriers

The Krait processor requires a barrier to be executed
between writing to L2CPUCPSELR and accessing L2CPUCPDR, to
ensure that the write to L2CPUCPSELR is reflected in the
access to L2CPUCPDR.

Change-Id: Ifda47c189721237786e5f3fefb8506bbd830d365
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Revert "msm: acpuclock-8960: Increase L2 speed to 1.35GHz"

This reverts commit 0432e43b621ca96b7f6a49284ffee66ec44b8a48.
Revert "msm: acpuclock-8960: Add voltage boost mode"

This reverts commit 334ff2e2540ef8d9720d91368804d4119abf9eae.
Revert "msm: board-8960: Change PM8921 SMPS 8 constraint voltages to allow 2.05 V"

This reverts commit 4df4101d78a6f4e7daec3c620986cae5044e2e4f.
Revert "msm: acpuclock-8960: Initialize regulators and bus_bw earlier"

This reverts commit 0a385e7687c6cdf09d1ed0392698de78bf6a410b.
Revert "msm: acpuclock-8960: Update kraitv2 frequency to L2 mappings"

This reverts commit 73b78c9144c9241f97e4985fb4b73668161e5924.
Revert "msm: acpuclock-8960: Lower maximum L2 clock rate to 1.2GHz"

This reverts commit e5c2d22ac348721aefb2bfb8231c23243efc0930.
msm: acpuclock-8960: Activate 8064 acpu frequency scaling

Do the following to enable the acpuclock driver
on the 8064:

1. Add new regulator consumer entries for krait2
   and krait3.
2. Remove cpu_is_* calls thus enabling bus and
   voltage scaling calls on the 8064.
3. Remove the stub in the cpufreq driver that
   prevents it from initializing on the 8064.
4. Add a call to the acpuclock init function in
   the 8064 board file, after the bus driver's
   init call.

Change-Id: I4f47f51241826b4056b40b012e964a9527db58f5
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
msm: acpuclock-8960: Add HFPLL regulator voting for 8064

8064's HFPLLs are powered by LVS7. Update the code to reflect
this.

Change-Id: Id091453cb20caebdc81cfb6920352ad3bb73734d
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: acpuclock-8960: Update regulator support for 8930 and 8627

8930/8627 uses the new pmic pm8038 so need to update the regulators
used by acpuclock driver to the corresponding pm8038 regulators.

Change-Id: I7771236cc1eed6f7b28fb456a4e8fbaa60544cc1
Signed-off-by: Tianyi Gou <tgou@codeaurora.org>
Revert "msm: acpuclock-8960: Confirm power-collapse before disabling CPU clocks"

This reverts commit 55018d240a11d65481bb925fcd031cceca4b0267.
msm: acpuclock-8960: Skip HFPLL regulator during PLL reprogramming

When briefly disabling HFPLLs to reprogram their rates, there is
no need to de-assert and re-assert requests for the PLL's power rails.
Skip these the regulator enable/disable steps to save potential latency
waiting for the regulator calls to return.

Change-Id: I1f00b00123178a27655fd0d70834ac809149e694
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: acpuclock-8960: Initialize regulators and bus_bw earlier

The init code assumes that the regulators have already been set
up to support the max CPU frequency. While this is true, the
fewer assumptions we make, the better. So, switch the ordering to
initialize the regulators before switching the frequency. This
also has the nice side-effect of not running the regulators at a
higher than required voltage for fast parts.

While we are at it, also change the bus init ordering so that we
can pick the bus bandwidth that corresponds to the freq the L2
will be initialized to instead of picking the max bandwidth
defined in the bandwidth table.

Change-Id: I58432f6e236a7077536e6565157b96c309df590d
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: acpuclock-8960: Lower maximum L2 clock rate to 1.2GHz

Significant testing has shown that L2 clock speeds above 1.2GHz
are not stable. Only allow the L2 to scale up to 1.2GHz.

Change-Id: I006fdca3e09bb97e1b60cec58a6a0680143e5715
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: acpuclock-8960: Update kraitv2 frequency to L2 mappings

Some power savings can be had by pairing different L2 frequencies
with cpu frequencies. Update the frequency tables accordingly. We
also thin out the available cpu frequencies so that only the max
frequency for a maximum voltage is used.

Change-Id: I0d5d70ca7dc80957f44bb64f1830e7fa578190bc
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: acpuclock-8960: Select QSB clock source during 8064 hotplug-remove

8064v1.0 hardware is subject to the requirement that the QSB clock
source must be selected prior to power-collapse to prevent a potential
clock source switching issue that may result in a CPU lockup. This is
similar to Kraitv1, so apply the Kraitv1 workaround to 8064.

Change-Id: I046f1a141fb6f033c616cb2c506d0838df1f5b13
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: acpuclock-8960: Skip regulator on first hfpll disable

When the HFPLLs are first initialized we don't want to direct the
RPM to disable the regulators for the HFPLLs until all the PLLs
are configured. Otherwise we'll end up in a situation where an
HFPLL is enabled but the regulator for the HFPLL is disabled.

For example, when the first HFPLL is initialized we may be in a
state where both CPUs are running at 918MHz using their
respective HFPLLs. When hfpll_init() disables the first CPUs PLL
to reconfigure its speed it will disable the PLL with
hfpll_disable(). The regulator driver will see that there are no
other votes for the regulator (even though the other CPU is using
its own HFPLL) and then disable the supply used for all the
HFPLLs.

Skip disabling the regulator on the first hfpll_disable() so that
we properly initialize all the votes for the regulators from the
PLLs and only drop the votes once all votes are initialized. If
the regulator APIs were in use there would have been an
unbalanced disable warning printed.

Change-Id: Id8c13e3076845d39b46a903296ed61d96490521d
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: acpuclock-8960: Fix regulator-related debug prints

Regulator names are not printed in all regulator-related debug messages.
Fix this and remove the duplicate __func__ prefix for these messages.

Also, the regulator names 'krait0_dig' and 'krait0_mem' were assigned for
all CPUs, not just Krait 0.  Change this so the number in the regulator
name matches the CPU number the regulator is associated with.

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