msm: cpr-regulator: change device tree vendor prefix to 'qti'.

New policy requires changing device tree vendor prefix from 'qcom'
to 'qti'. Also change device tree files for msm8610, msm8226 and msm8926.

Change-Id: I57c8c9d14ffa3ddd3671f406cfa2011eb23e66e4
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: cpr-regulator: change cpr_read_efuse_row api.

Add a flag in cpr_read_efuse_row api to make it choose
to read register directly or read through SCM.

Change-Id: I3031dfd1c7cfffb880c49e5f1708b1436fdd2897
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: cpr-regulator: add support for conditional minimum voltage.

Certain targets have VDD_APC minimum voltage constraints which are
imposed if the mem-accel fuse has not been programmed. Add two new
device tree properties to capture the row offset and expected value
of the mem-accel fuse as well as to capture the minimum VDD_APC voltage
to enforce if the mem-accel fuse has not been programmed with the
expected value.

CRs-Fixed: 580585
Change-Id: Ifd770b33d74b2bc9cf37dd2b1817e1424a5ee8f3
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
ARM: dts: msm: specify conditional VDD_APC minimum voltage for msm8226.

Restrict the minimum APC voltage to 1.14V when the mem-accel fuse has not
be programmed as expected.

CRs-Fixed: 580585
Change-Id: Ia506efb15c7599d79c5561163879d82910db84f8
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
ARM: dts: msm: reduce CPR turbo floor voltage for msm8226.

The device tree property qti,cpr-cond-min-voltage = <1140000> along with
an appropriate qti,cpr-cond-min-volt-fuse property value ensure that the
CPR turbo floor voltage is restricted to 1.14 V on devices that cannot
operate at lower voltages.

Therefore, reduce the default CPR turbo floor voltage to 1.1 V in order
to save power on devices that can operate at the lower voltage.

Change-Id: Ic939d4a7b1c4da0a28dd779fe6a900310ae9fab7
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: cpr-regulator: modify the dts definition for cond-min-volt.

Previously, cpr-cond-min-volt-fuse defined the fuse row number and the
value used to compare with the whole row efuse value. The cpr-regulator
driver would then conditionally apply a higher CPR floor voltage for all
voltage corners if the efuse value differed from the expected value.

However, only a subset of the bits in the efuse are used for the
cond-min-volt feature. If any of the other bits in the fuse are set, then
the cpr-regulator driver incorrectly applies the higher floor voltage even
if the cond-min-volt bits are set correctly.

Modify the cpr-regulator driver and the cpr-regulator device tree
properties so that only specific bits in the fuse are compared to the
expected value. If the value of the cond-min-volt bits in the fuse is
not equal to the value defined in device tree, then set the MIN_VOLTAGE
flag.

Change-Id: I7de04e17dfa93fcb638e29a1dcc5e9072de26cb8
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: cpr-regulator: add pvs voltage uplift workaround.

There are some parts which require higher than expected voltage. Add a
workaround to check the condition in fuse and uplift the voltage and
quotient accordingly.

Change-Id: I59f821320e5e97fc2334ae7617a0045edb5cc970
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
ARM: dts: msm: enable pvs voltage uplift workaround for msm8226.

Some 8x26 parts have lower pvs voltage than expected. Enable uplift
workaround of 50 mV on those parts under the specified conditions.

Change-Id: I3d8689ca0c5d576b1dd9057e36f67ea3622b80a1
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: cpr-regulator: add dummy read to bypass false register value.

There is an issue in certain CPR HW, which requires ignoring the
first read of IRQ_STATUS register in ISR.

CRs-Fixed: 570495
Change-Id: Ib1a57a3da3c60ffb5af3669947a4eb09dbb8c255
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: cpr-regulator: add debug message in cpr_scale.

Add debug message in cpr_scale to show gcnt and quotient when ceiling or
floor is hit.

Change-Id: I6bb6f5160f9f0b3d9140384871b0258b0ecac388
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: cpr-regulator: add support for virtual corner based quotient scaling.

The current cpr-regulator driver implementation uses the same CPR target
quotient, which is read from a fuse, for all CPU frequencies handled by a
given voltage corner. This results in unnecessary additional power
consumption when operating the CPU at one of the lower frequencies handled
by one voltage corner. Hence change the driver to adjust the CPR quotient
value according to the virtual corner corresponding to the CPU frequency.

CRs-Fixed: 583719
Change-Id: Ia95688b8c6e88d14da1ac9311d73148802105d0a
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: cpr-regulator: change CPR_CORNER to CPR_FUSE_CORNER.

New changes introduce virtual corner concept as opposed to cpr_corner.
Cpr corners in existing code are all cpr fuse corners. Hence change them
to distinguish cpr fuse corner from cpr virtual corner.

Change-Id: I086b29cadb23edfdff583f21f29efad4b35be5e1
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
ARM: dts: update frequency to corner and quot mapping on msm8226 and msm8610.

Some devices need to adjust their CPR quotient value according to the cpu
frequency. The existing configuration uses the same fuse target quotient
for each frequency in a given corner. This configuration is not power
efficient as some corners have a large range of frequencies. Hence use a
virtual corner for each frequency for power saving purposes.

CRs-Fixed: 583719
Change-Id: I90113c4ad26c792c849378ec192bfde4ff2ec199
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
ASoC: wcd9306: unvote pm runtime after slim disconnect port

Codec shutdown removes vote for pm runtime and subsequent call
to slim disconnect port would cause failure as it would race
with pm suspend call. Unvote for pm runtime only when there are
no active dais and remove the vote once the slim ports get
closed successfully at the end of audio session.

CRs-fixed: 566520
Change-Id: Ib620f1644097f69a8180ab96f75d170d068acac5
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
msm: camera: Update sensor mount angle and position

Update sensor driver to add sensor mount angle and
position as part of media entity flag. This info
is used by upper layers to get the info from
media device entity insted of opening camera
to reduce the launch latency.

Change-Id: I33e047cd52a87e9770de10c101631864b8737501
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
msm: ADSPRPC: Add checks for erroneous values.

Check for invalid parameters passed in user invocation
and validate the return values using appropriate macros.

Change-Id: If529873d025ac0c13725efbedda5a58fae327722
Acked-by: Sathish Ambley <sambley@qti.qualcomm.com>
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: ADSPRPC: Close SMD channel after RPC session ends.

The SMD channel open request needs to be delayed as the
remote processor may not be up early on when the driver
is initialized. The SMD channel is opened when the first
RPC session is opened and closed when the last RPC
session ends.

Change-Id: I0bbff2956c3e367312d4344107340feb29e643ab
Acked-by: Sathish Ambley <sambley@qti.qualcomm.com>
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: ADSPRPC: Save and restore contexts when interrupted.

While a RPC session is in progress, wait could get interrupted
as a result of device entering power collase and the system call
retried once the device leaves power collapse. This requires that
the RPC session context is saved and restored across these
interrupts to avoid duplicate invocations being sent across to
the remote processor.

Change-Id: I71141c13da7be3d33e13305e0744148921123160
Acked-by: Sathish Ambley <sambley@qti.qualcomm.com>
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
kref: Implement kref_get_unless_zero v3.

This function is intended to simplify locking around refcounting for
objects that can be looked up from a lookup structure, and which are
removed from that lookup structure in the object destructor.
Operations on such objects require at least a read lock around
lookup + kref_get, and a write lock around kref_put + remove from lookup
structure. Furthermore, RCU implementations become extremely tricky.
With a lookup followed by a kref_get_unless_zero *with return value check*
locking in the kref_put path can be deferred to the actual removal from
the lookup structure and RCU lookups become trivial.

v2: Formatting fixes.
v3: Invert the return value.

Change-Id: I391623ee7458428eab6d7f361630f8646d6790b0
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Git-commit: 4b20db3de8dab005b07c74161cb041db8c5ff3a7
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[shrenujb@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>

Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
introduce kref_put_mutex().

equivalent of
	mutex_lock(mutex);
	if (!kref_put(kref, release))
		mutex_unlock(mutex);

Change-Id: I59f3dd1425e871e0b73b463447f74bc66d65ba0b
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[mitchelh@codeaurora.org: trivial conflict due to moved code]
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>