Sync cpufreq with CAF 3.5

msm: cpufreq: Add msm_cpufreq debugfs file to show CPU -> L2/BW mapping

Example output:
cat /sys/kernel/debug/clk/msm_cpufreq
  CPU (KHz)  L2 (KHz)  Mem (MBps)
     300000    300000         600
     422400    422400        1200
     652800    499200        1600
     729600    576000        2456
     883200    576000        2456
     960000    960000        3680
    1036800   1036800        3680
    1190400   1036800        3680
    1267200   1267200        6400
    1497600   1497600        6400
    1574400   1574400        6400
    1728000   1651200        6400
    1958400   1728000        7448
    2265600   1728000        7448

Change-Id: I20df8c3778c0fcd0ef1f369acb1cb72cf5334812
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>

msm: cpufreq: Remove unused msm_cpufreq_set_freq_limits() API

The msm_cpufreq_set_freq_limits() is a mach specific way to set CPU freq
limits. The thermal code no longer uses this API and instead uses the
standard INCOMPATIBLE notifiers provided by the common CPUfreq framework.
Since this API is no longer needed, delete it.

Change-Id: I5c07b17195d4e4b75cdd4d82f8e7cb6cb6f3e199
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>

Conflicts:
	drivers/thermal/msm_thermal.c

msm: cpufreq: Avoid NULL clock pointer references

The MSM CPUfreq driver defines a mapping from cpu number to clock
pointer. On SOCs with synchronous cpus, only the mapping for cpu#0
is defined, even though there may be more than 1 cpu. Handle this
case by skipping certain unnecessary initialization steps for SOCs
with synchronous cpus.

Conflicts:
	arch/arm/mach-msm/cpufreq.c

Change-Id: Iaeba7a8615e3cb7da2c725250db92595450bfa46
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>

msm: cpufreq: Correct synchronous cpu logic

Fix an incorrect patch conflict resolution which results in failing to
initialize the cpufreq policy correctly when using an old acpuclock driver
version.

Change-Id: If8743a2608e720258ebc710718c3041144c00f10
CRs-fixed: 612226
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>

msm: cpufreq: Fix msm_cpufreq_get_freq() for sync CPUs

When CPUs are in sync, only CPU0 has a non-NULL cpu_clk. clk_get_rate()
on other cpu_clk will return 0. msm_cpufreq_get_freq() is used in multiple
places in cpufreq framework to determine current hardware frequency.

Fix msm_cpufreq_get_freq() to return the right hardware frequency for
systems with synchronous CPUs.

Change-Id: I6a880764ad51fa9a257a328798b38d574750686a
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

msm: cpufreq: Move the enabling of the CPU/L2 clocks to CPU_STARTING

It is a requirement of PLLs in MSM SoCs that the PLL power
supplies be enabled while the PLL is running. If the PLL is
locked and outputs enabled, turning off the regulator(s)
supplying the PLL will cause the PLL to enter an unpredictable
state.

Now in the CPU_UP_PREPARE notifier, the CPU clocks are prepared
and enabled, causing the source HFPLLs to also turn on. Note
that the CPU isn't clocked yet. It is possible that execution is
pre-empted and the CPU running the notifier enters power
collapse. If all other CPUs also enter power collapse, then it
is possible for an RPM notification to go out, allowing the RPM
to transition the Apps processor to its sleep set. This can
result in the HFPLL supplies being turned off while the HFPLL is
running, violating the requirement mentioned above. Once the CPU
is unclamped, the CPU is effectively unclocked, due to the HFPLL
being in an unknown state.

There is a check that is enabled in the PM code's CPU_UP_PREPARE
notifier callback. This check ensures that the problematic RPM
notification cannot occur until the core that is being brought
online also enters power collapse. However, there is no ordering
guarantee between that PM's hotplug notifier callback's execution
and the cpufreq hotplug notifier callback's execution. This
ordering depends on program link order, which is unreliable.

It is necessary to ensure that once the HFPLL is enabled, the
RPM cannot transition apps to its sleep set. Move the enabling
of the CPU clocks to the CPU_STARTING notifier, which runs on
the CPU bring brought online. The CPU_STARTING notifier is
guaranteed to run after the CPU_UP_PREPARE notifier, which
implies that the aforementioned do-not-notify-rpm check is
executed *before* the HFPLL is enabled. Therefore even if all
cores enter power collapse after the HFPLL is enabled, the
HFPLL supplies are guaranteed to stay on, or the CPU clock
is switched to the safe source and the HFPLL is turned off.

CRs-Fixed: 622738
Change-Id: I136841405806c07e755919859e649ded0c719abb
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/cpufreq.c

msm: acpuclock: Add a null check for acpuclk_data

If acpuclock fails to probe before a client calls acpuclk_get_rate,
a null dereference will occur. Fix this by adding the appropriate
checks.

Change-Id: If873a64711e9cc807b1734996f7c9358bb08161a
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>

msm: acpuclock: Fix acpuclk_data null pointer dereference

If acpuclk_data is null, dereferencing it in acpuclk_get_switch_time
causes a kernel panic.  Add pointer check to fix that.

Change-Id: I69b92671c8cf26cb45ec8f1193c147be2ebe4c16
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

devfreq: Add MSM CPUfreq governor

The MSM CPUfreq devfreq governor determines the CPU to DDR bandwidth vote
based on the current CPU frequency of all the active CPUs.

This functionality used to be a part of the MSM CPUfreq driver that
directly voted for the CPU to DDR bandwidth using MSM bus scaling APIs.
This refactor decouples CPU to DDR BW scaling from CPU frequency and allows
switch between various CPU BW governors.

The bandwidth values in the msm-cpufreq table have to be updated since the
new CPU BW driver does the MBps to Bps conversion correctly. The MSM
CPUfreq driver used to do * 1000 * 1000 to convert from MBps to Bps instead
of doing * 1024 * 1024.

Change-Id: I184f09d628a1b27d52506d2f760d65831f1a1110
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>

Conflicts:
	arch/arm/boot/dts/msm8226.dtsi
	arch/arm/boot/dts/msm8974.dtsi
	arch/arm/boot/dts/msm8974pro.dtsi
	arch/arm/mach-msm/Kconfig
	arch/arm/mach-msm/devfreq_cpubw.c
	drivers/devfreq/Kconfig
	drivers/devfreq/Makefile