PM / devfreq: Add a new target flag for the performance governor

The new flag for the devfreq profile->target() function is used
by the performance governor to notify the driver that the device
should wakeup on the max frequency.

Change-Id: I91c2d649177bdd1841a087a2125d1cdbc979f5c1
Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>
sec dts
msm: devfreq_cpubw: Add devfreq driver for CPU to DDR bandwidth voting

This driver registers itself as a devfreq device that allows devfreq
governors to make CPU to DDR IB/AB bandwidth votes. This driver allows the
governors to be agnostic of the bandwidth voting APIs, the number of CPU
master ports or DDR slave ports, the actual port numbers, the system
topology, the available DDR frequencies, etc.

Change-Id: If055ddd580afd41f9668b111e6c09a047488b2e0
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Revert "dts: msm8974: add 2.5ghz frequency"

This reverts commit 0ca4a8a8bee6005729b7e86ded1e8e1685666be5.
sec dts
Revert "msm: clock-krait-8974: User voltage control for msm-cpufreq device"

This reverts commit 904514e4b63aecc4714813c66d70a1c688cecaa7.
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>
sec dts
devfreq: Add CPUBW HW monitor governor.

The CPUBW HW monitor devfreq governor uses the Krait L2 PM counters to
determine the bandwidth needed by the Krait CPU subsystem. This governor
can be used in conjunction with the CPUBW devfreq device to dynamically
scale the DDR frequency based on the demand/actual usage from the Krait CPU
subsystem. Since this governor uses the Krait L2 PM counters it can
conflict with certain profiling tools.

The Krait L2 performance monitor counters have the capability to count the
no. of read/write transactions going out the master ports. They also have
the capability to raise interrupts when they overflow. This driver uses
those counters to determine the true usage of DDR from the Krait processor
subsystem and then recommends CPU DDR BW votes based on the measured values
and the following tunable parameters.

The driver provides various tunables that allow it to be tuned more in
favor of power or performance:

- io_percent: The percentage of the CPU time that can be spent waiting on
  memory I/O. Lower value is better performance and worse power.

- sample_ms: The sampling period in milliseconds. This only affects the
  sampling period when DDR use is ramping down or is increasing very slowly
  (See tolerance_percent).

- tolerance_percent: The minimum increase in DDR use, compared to previous
  sample, that will trigger an IRQ to immediately bump up the bandwidth
  vote. It's expressed as a percentage of the previous sampled DDR use.

- decay_rate: The parameter controls the rate at which the history is
  forgotten when ramping down. This is expressed as a percentage of history
  to be forgotten.  So 100% means ignore history, 0% mean never forget the
  historical max. The default 90% means forget 90% of history each time.

- guard_band_mbps: This is a margin that's added to the measured BW (and
  hence also the Bus BW votes) that's present to account for the time it
  takes to ramp up the DDR BW while the CPU continues to use the DDR.

- bw_step: All BW votes are rounded up to multiples of bw_step. The default
  value is 200 MB/s that turns out to ~25 or 12.5 MHz based on the SoC. A
  smaller value would mean more frequent bus BW changes. A higher value
  would mean less frequent BW vote updates, but also means at times an
  unnecessarily higher BW vote (due to the rounding up).

Change-Id: I88629a3e545cdca7160af8f8ca616ecc949d9947
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Panwar Vivek <vpanwa@codeaurora.org>
PM / devfreq: Add new flag to do simple clock scaling

Add new flag "simple_scaling" to on demand governor so that
the clocks can be scaled up only when the load is more than
up threshold and can be scaled down only when the load is less
than down differential data as provided within
struct devfreq_simple_ondemand_data.

Change-Id: Ibc6ab6297c1b64b6e6eaaa76d735d0b9ae0f6477
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
devfreq: governor_cpubw_hwmon: Remove sample_ms and fix round up of freq

devfreq already provides a sysfs interface for changing polling/sampling
period. So, there is no need for the governor to separately expose
sampling_ms. Also, sampling_ms had to be explicitly updated whenever
polling_ms was updated for the governor to function correctly. Make the
interface simpler by combining sample_ms with polling_interval control
provided by devfreq.

The rounding of freq to multiples of bw_step is unnecessary since the
devfreq device already does the rounding to the next valid level. Rounding
of AB to multiples of bw_step is still necessary since it's a vote that's
summed up and doesn't have a direct 1-to-1 mapping to frequencies.

Also update default bw_step to 190 MB/s instead of 200 MB/s to account for
the fact that MB/s to MHz conversion needs to take into account the
difference in the meaning of M (2^20 vs 10^6) between MB and MHz. Similarly
also update io_percent to 16.

Change-Id: I5fea989c647955103de3813be8eb9ec612f131bc
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
remove old
msm sec dts
ARM: dts: msm: Add kraitbw-l2pm device for 8974.

This device provides the hardware details needed by the kraitbw_l2pm
devfreq governor to measure the DDR usage from the Krait CPU subsystem and
the IRQ that's needed to react quickly to usage changes.

Change-Id: I778a36839c9b2279ab2d912715cd7eba091fe25f
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Panwar Vivek <vpanwa@codeaurora.org>
ARM: dts: msm: Modify bus vector for RNG client on msm8974

Modify the RNG (Random Number Generator) bus vector to use a different
originating master id, this change helps alleviate some slowdowns in boot
time noticed in targets where CPU is artificially bus throttled below a
threshold frequency.

Change-Id: Idf2a1d128f56e6aafebcbf0184ef2454d385be34
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
ARM: dts: msm: List all possible BW levels in cpubw for 8974

With the cpubw_hwmon devfreq governor available in Krait based CPUs, it's
important to list all the possible BW levels to get all the benefit from
the cpubw_hwmon governor. Also fix the use of a non-existent BW level in
msm-cpufreq device.

Change-Id: I9a2725f459914296765ed70cabe470e643b02381
Signed-off-by: Panwar Vivek <vpanwa@codeaurora.org>
dts: msm8974: sync with caf changes
msm: hotplug: Add MSM Hotplug driver
msm: hotplug: Max 1036MHz during screen off
msm: hotplug: Remove spinlock in load stats

It's too expensive and not nessecary.