msm: kgsl: devfreq_target requests can happen during SLUMBER

Bus updates should be ignored if the bus is already off.  The bus
will wake at the default frequency for the active power level.

Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: kgsl: when unmapping from the mmu flush the entire tlb

Flushes the entire tlb when calling mmu_unmap to make sure there
is no race condition between unmapping and freeing the pages.

Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock: Allow msm_clock_init to be invoked multiple times

In preparation for a series of changes that move MSM clock
controllers to the Linux device model, allow msm_clock_init
to be invoked multiple times (once for each clock controller).

Change-Id: I0d56612c660f020ea762feb468234813cff0db22
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
spi_qsd: Add vote for clock path

Currently the spi driver votes for its core clock. However, it is
possible that the core-clock's source will be off. When the source
is off, the spi core is not clocked. This patch adds voting for
the entire clock path, thus guarantee clocking to the spi core.
Voting for the path cost a few msecs. A client may choose when
to pay this overhead. By default the votes takes place in the
runtime-pm callbacks which tie to transaction requests. A client
may choose to invoke these callbacks itself whenever it likes
by directly calling the driver's runtime-pm. A third option is
to set the active_only flag in platform data which results in the
callbacks being called when the application processor power state
changes.

CRs-Fixed: 478465
Change-Id: Ib866399c0e84a875a19a0d1506d77bbe77d5fe61
Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: acpuclock-cortex: Detect bootloader cpu configuration

Detect which cpu rate is currently selected by the bootloaders during
probe. If the rate is invalid, then set the cpu rate to maximum.

Change-Id: I316d5de76133e76993a47b0d2917fd35bc5dd590
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock-pll: Force PLLs off before reprogramming

PLLs can be enabled by the bootloaders without linux's knowledge. Ensure
the plls are off before changing their rates.

Change-Id: I77d1519117257570a1f3fa2e451d88b20776a013
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock-8226: Fix incorrect voltage limit value

The hw and sw frequency plan rounded the SVS frequency limit for the
vcodec clk to different values.

Change-Id: I721556cbdce7923f287eb733ccf16701ea7d3347
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: buspm: Enable busPM for targets which support bus scaling.

BusPM module should not depend on individual target configs
as it previously was. Fix this by tying busPM module with
MSM_BUS_SCALING conifg and enable it on all targets where
bus scaling is enabled.

CRs-Fixed: 486454
Change-Id: I5e44b6b63dd8577a5db6fa6f34526af0a4933c82
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: subsystem_restart: Change the error ready log message

The error services interrupt log message appears as if it is
reporting an error. So, change it so that it does not appear so.

Change-Id: I84049af9d369d1c87547225813ec6cf1c4a66db5
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock-generic: Handle round rate return values greater than LONG_MAX

The return type of clk_round_rate() is long. So, technically it can return
only rates as large as LONG_MAX (~2.1 GHz). But CPU clocks can already go
past 2.1 GHz and any return value greater than LONG_MAX will appear as a
negative number to the caller.

So, make the clock-generic implementation a bit more selective/intelligent
about treating negative return values from clk_round_rate() as errors. If
the returned negative number is not one of the standard error values
(IS_ERR_VALUE), then treat the negative long number as an unsigned long
rate.

Change-Id: I27383bdb74ed6986667fee681005adec7b16bde9
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock-8610: Correct bimc_clk measurement mux select

The bimc_clk measurement mux select value is wrong.
Fix it so that the right clock is measured.

CRs-Fixed: 495360
Change-Id: I3230817fb9f5851d0c98a52338e8cb74a3e2cef4
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock-8974: Support 8974ac frequency plan

Update frequency tables and fmax settings for certain
clocks to match the latest 8974ac frequency plan data.

Change-Id: Iad9d7485eeae0c9f21f5829a96fab355fa575bd2
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock-rpm: Correct is_enabled implementation for RPM-SMD clocks

Clocks using the RPM-SMD driver have no way to query
clock state from the RPM. Therefore do not use the
get_rate function to figure out the enable-state of
the clock.

Change-Id: I4d142c716a4e41e54185e4ed4fe9feb33a1c2427
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: acpuclock-cortex: Select freq plan based on speed bin value

Due to process variation, not all hw has the same max speed. Duplicate
each speed_bin twice to allow greater flexibility between process yield
and chip demand. The bin values are chosen so that additional fuses can be
blown once to change between bins without the use of the multipurpose
redundant fuses.

Change-Id: I2e4f8c5c4d29e0461b455a3bd46a884bb43f6c20
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: krait-regulator: enable support for KPSS v2 hardware

KPSS version 2.1 introduces a hardware sequencer which executes
the necessary steps to switch between BHS and LDO krait power modes.
The driver has to set the APC_PWR_GATE_MODE register to initiate a
switch between LDO and BHS Krait power modes. Modify the driver to
use this hardware sequencer.

Also, switch to the V2 SPM sequence with the delays added for
HW sequencer to idle.

Also, with the V2 sequences, it is expected that APC_PWR_GATE_CTL
register be configured once before using the APC_PWR_GATE_MODE register to
switch between LDO and BHS.

Update the code such that for secondary cpus APC_PWR_GATE_MODE is
written to after configuring APC_PWR_GATE_CTL in the
secondary_cpu_hs_init() function. Note that secondary_cpu_hs_init() is
guaranteed to run only once for each secondary cpu when that core is
brought up for the first time. Subsequent hotplug in/out of that core
do not take this code execution path.

For boot cpu, since it is up and running, its APC_PWR_GATE_CTL
should already be initialized. So for boot cpu configure its
APC_PWR_GATE_MODE register right at probe time. secondary_cpu_hs_init()
isn't invoked for boot cpu.

Change-Id: Ie5584c12f47283cad8834ccdb3d4d44c66305a22
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock-8974: Fix 8974ac gpll4 and mclk changes

GPLL4 only exists on v3 variants, and shouldn't be in the lookup table
for v1/v2.  Camera MCLK is changed to match its clock type.

Change-Id: Id15313bfcaed783f7f835ff75f651e38d4bad8de
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: acpuclock-8974: Add support for 8974v3 speed bin

Add v3 frequency and voltage data corresponding to the voltage plan
for bringup.

Change-Id: I02f8885a5bc7798c5cfcae34cf952675f346b208
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock: Add a CXO voter for the LPM driver

The Low Power Mode resources driver needs to vote for
CXO in certain conditions. Add a voter clock for that
driver to the 9625/8226/8610 clock drivers.

Also, while we're here, create voter clocks for CXO
wherever necessary.

Change-Id: I07c9aed2ab67a58d296041a62049de63277995cd
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
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>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: acpuclock-8974: Apply 8974Pro bringup workaround

Fix soc version detection for 8974Pro and force 8974ab to use bringup
voltage plan.

Change-Id: I84bc7bf0912223b3826b8420c19c9e93e6a9f816
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>