msm: board-8960: Change PM8921 SMPS 8 constraint voltages to allow 2.05 V

Hardware characterization has shown that the system operates
without any problem when the voltage of SMPS 8 is lowered from
2.1 V to 2.05 V.  Therefore, change the constraint range for
SMPS 8 to include 2.05 V as a lower bound.

At the same time, change the voltage requests of the two SMPS 8
consumers: acpuclock-8960 and clock-8960 to use the new, lower
voltage value.

CRs-Fixed: 355505
Change-Id: I977d1deea84328a0c0dd93181af04a9435cfa8c2
(cherry picked from commit: 9a81d6c7c32e21721f886a338ca6d80fb5d4a88b)
Signed-off-by: David Collins <collinsd@codeaurora.org>
Revert "power: pm8921-bms: fix approach fcc"

This reverts commit 78f7f1f4ce2d57c4de14c718a31920d620d0c5e5.

Change-Id: Ibfbbcd78d2ebd5b3b9aed122da56102b3ab91b67
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: approach fcc if outside the scope

The existing algorithm discards the learnt FCC (full charger capacity)
if it is differs by more than 3% of the original. It could happen that
a battery in field doesn't confirm to the FCC degradation of the
profiled battery. So instead of discarding, limit the new FCC to 3% of
the original if it is beyond that value.

Also update the algorithm to learn FCC values only if the charging
began when the battery was lower than 30%. This avoids learning
FCC when the battery was nearly full - avoiding a faulty value being
learnt.

Change-Id: I0bd939517eddcc2de702397628de3309d0855644
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: fix approach fcc

There is a bug in the code where upon end of charging, the delta
fcc is not divided by 100. This causes incorrect fcc values to be
learnt.

Fix it by correctly diving the increase/decrease by 100 for new
fcc estimation.

Change-Id: I8426a450075dd4d9f1ff02009ecbf39bae8aca30
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: adjust soc

It was observed that the soc(state of charge) reported by the bms was off.
This lead to the phone shutting off because the battery voltage got very
low (UVLO). The expected behaviour is that as battery gets depleted the soc
is reported as 0 by the driver and the system executes a clean shutdown.

Avoid this situation by estimating the instantaneous SOC and adjusting the
reported SOC. The reported SOC is such that it approaches the estimated
soc.

The algorithm to calcualte soc est is as follows
1. Get the simultaneous vbatt and ibatt readings.
2. Get the rbatt of the battery
3. estimated open circuit voltage ocv_est = vbatt + (rbatt * ibatt)
4. calculate rc_est = calcualte_pc(ocv_est) * fcc;
5. soc_est = (rc_est - uuc)/ (fcc - uuc)

The soc est indicates what would be the current soc of the battery solely
based on instantaneous ocv (open circuit voltage) of the battery.

Note that soc_est is subject to fluctuations as the load on the battery
changes - it needs to be weighted accordingly. Let "n" inversely define how
quickly soc approaches the soc_est i.e. a high value in n indicates the
approach is slow and a low value of n indicates we approach the fast. This
implies that the value of n should be smaller as soc_est goes to 0.

Choose a value of n based on where soc and soc_est
are. Experiments showed that

n = min(200, max(1, soc + soc_est + last_soc_est))

yields expected adjusted results. last_soc_est is the soc_est the last time
soc request was made.

Once n is calculated, the last_ocv_uv is adjusted such that soc moves 1/n
steps closer to soc_est. This new soc value "soc_new" is the adjusted
value reported to the userspace.

CRs-Fixed: 349817
Change-Id: I807f051fc1e63b40740e0e0c3a50857ad958bcb6
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8xxx-ccadc: fix return value in conversion

When the ADC_WAIT_COUNT is exceeded the return value should
be non-zero to indicate that there was an error when doing
the conversion.

CRs-Fixed: 347892
Change-Id: Ic35359b153069e0cbca7f73714ce3f7387718694
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
msm: cache_erp: Do not panic on TLB multi-hits

TLB multi-hit events may be reported as a result of a
benign condition, so there is no need to panic the kernel
if such a condition is encountered. A TLBIALL operation
needs to be performed to avoid an interrupt storm if the
condition persists.

Change-Id: I91219c299e0915b3e9e0b9d7a672b401e1479d71
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit bddae7c5467da0dac4adec2b2e32c399033e6e51)
msm_fb: display: enable MDP interrupts base on panel interface

Enable necessary MDP interrupts base on panel to avoid
triggering dma_s isr handler.

Crs-fixed: 331668
Signed-off-by: kuogee hsieh <khsieh@codeaurora.org>
(cherry picked from commit bbcf4477c7e7d8ba7208e179f55bc8e550de08a7)

Conflicts:

	drivers/video/msm/mdp4.h

Change-Id: Ia1c8dfc2de5feae6269644a3a6b0d866e6b0ac1d
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: improve handling of DONT_MAP_HOLE_AFTER_MEMBANK0

The code to avoid mapping the hole after memory bank 0
located the start and size of this hole after running
generic initialization code which needed to convert
physical addresses to virtual ones and vice-versa
beyond this hole.

While this didn't prevent the kernel from booting, this
isn't clean, and in fact it was giving us more vmalloc
space than the config file specified (and as a result
there was less lowmem than expected).

The code to locate the hole now runs before this
initialization code.

CRs-Fixed: 352258
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
(cherry picked from commit 31a949b5c5004f017e4adfa86f4a136025acdcd4)

Change-Id: I8bfef1dd16c0d4759976a40baace0cdb960620d6
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: move fixed area start lower so that 768M systems work

The start of the fixed area was at 0xb0000000, but
on 768M 8960 systems this memory doesn't exist.
Since the start of the fixed area must be the
same on all 8960s, the fixed area start is
lowered to 0xa0000000.

CRs-Fixed: 349125, 352258
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
(cherry picked from commit 4d4f4484277f99c85cc32d1878a32b07f74bead2)

Change-Id: Ib1727615e4ef5c298ed492230da71552e86b87d5
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: kgsl: Create ion client in the probe function

Move the call for creating the ion client from kgsl_setup_ion to
kgsl_device_platform_probe. Keeping the create ion client call linked to
kgsl_ioctl_map_user_mem made the user process which first used this
ioctl be forever visible as an ion client in debugfs, even when the
process itself had terminated. Creating ion client in probe ensures that
kgsl appears as the ion client in debugfs and avoids confusion.

CRs-fixed: 349112
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
(cherry picked from commit f48af7f2fc1f2c863c48b6d4c65f83ef65228eb7)

Change-Id: I193cd495939210274c7e5d7a6910c319355f3205
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
Revert "power: pm8921-charger: remove set_usb_power_supply_type"

This reverts commit 70f6cdc262dc3e2bb3fb8ac1c56a216f0600d441.

Allow customized charger drivers to leverage the USB power supply
type information.

CRs-Fixed: 354361
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit 86034027d00919ed33c2e1c09499698a71863e72)

Change-Id: I623c79c55e1168cf83d8fe5791061b0f26db89e6
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
Revert "USB: OTG: remove pm8921_set_usb_power_supply_type"

This reverts commit 34b874562012c3453da20059094992140ca1ea61.

Revert the removal of the set_usb_power_supply_type to allow
customized charger drivers to leverage off of the information
provided by the usb driver.

CRs-Fixed: 354361
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit 081a3e2fac5f1080e25784978ef02fb051397935)

Change-Id: I8977843a74f4cc19622b1d41c8311637f696dd7f
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
power: pm8921-charger: Correct USB online reporting

When a USB charger is first connected to the device
the USB driver determines the maximum available charge
current. If the USB driver determines that a wall charger
is connected there is a possiblity of the USB power
supply type to falsely be reported as online.

Fix this by only reporting the USB online state if the
targeted maximum USB current is less than 500 mA. This
means that there was no wall charger ever connected and
AICL will not be utilized.

CRs-Fixed: 354361
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit af51571d389c397374e22584fdcb400a742d0dd6)

Change-Id: Ie8ada5dbdc60c8389792d5e677b31a5a9a41f193
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
mmc: core: Detect card removal on I/O error

To prevent I/O as soon as possible at card removal, a new
detect work is re-scheduled without a delay to let a rescan
remove the card device as soon a possible.

Additionally, MMC_CAP2_DETECT_ON_ERR can now be used to handle
"slowly" removed cards that a scheduled detect work did not
detect as removed. To prevent further I/O requests for these
lingering removed cards, check if card has been removed and then
schedule a detect work to properly remove it.

Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
[subhashj@codeaurora.org: Fixed merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit c331348e4d5618259d504bbed4a8989b59c17e33)

CRs-fixed: 354758
Conflicts:

	include/linux/mmc/host.h

Change-Id: I28e8ab0c6ea391a457255aa4c922fd957d43d6b0
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
mmc: msm_sdcc: detect card removal on I/O error

This change defines MMC_CAP2_DETECT_ON_ERR cap which will
let MMC core layer to detect card removal on any I/O error.
If this cap is not enabled, MMC block layer will keep
throwing the I/O errors for all the requests in MMC block
queue.

Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit 6bb34a8e987f7aefb4533678641e5565ca125e59)

CRs-fixed: 354758
Conflicts:

	drivers/mmc/host/msm_sdcc.c

Change-Id: I55f39df1ab4c4f6b43fec9ffc0cb6bc219b7b0c9
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: audio: qdsp6v2: Fix ADM RTAC

Use the COPP ID instead of AFE index in the
token field of APR packet so the callback is not
rejected.

CRs-fixed: 351089
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
(cherry picked from commit 1dc9f8a98ed9a01ce638a408aebed7a59ab10624)

Change-Id: I87041753b38171c2e3cf8ef1f975616efe68056d
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
Merge "msm: move fixed area start lower so that 768M systems work" into ics_chocolate
Merge "msm: improve handling of DONT_MAP_HOLE_AFTER_MEMBANK0" into ics_chocolate
Merge "Revert "power: pm8921-charger: remove set_usb_power_supply_type"" into ics_chocolate