msm: hotplug: remove code related to cpu_killed

Earlier the completion event cpu_killed was used to synchronize
notify to hot plug framework that the CPU is dead. But now it is
replaced with another completion event cpu_died and it is placed
in the hotplug framework itself. So there is no need for a
platform to implement a completion event.

But in msm platform driver the completion event related code
was not removed with the changes in hotplug framework. This
patch removes the unused code.

Change-Id: I4418e5e397821e39a7b6a6efa997c4a866e9b46b
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
msm: hotplug: Block hotplug removal of CPU0

Hotplug removal of CPU0 is not currently supported. Attempts to
remove it may result in undefined behaviour. Explicitly block
any such attempts before other hotplug notifiers get the chance
to run by setting the notifier priority to INT_MAX.

Change-Id: I9e1f5b4a0db554295a097220417f2bdf4c690f5f
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: cpuidle: use format string in snprintf

Currently no format string specified in snprintf
and this leds to security vulnerability. Use format
string in snprintf function.

CRs-fixed: 562232
Change-Id: Id67efe6952071bda8119ae2be907ea0b15da2797
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
msm: idle-v7: Separate PC termination for hotplug

When a core is power collapsed as a part of hotplug the state of the CPU
isn't restored and hence there isn't a need to save the registers. This
change is needed by a subsequent patch that will reserve a DMA memory to
save the register contents. The DMA memory region isn't available until
arch initcall and the kernel thermal module could hotplug a core for
thermal considerations.

CRs-fixed: 489391
Change-Id: Idf6ec5212482ccff91500edc4988516389189627
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>