msm_fb: hdmi: HDMI resume delay

Remove the delay in HDMI resume sequence by not waiting for HPD
to be switched on. HDMI panel will not be turned on by default
when the device resumes and would instead be turned on by HPD
sense if it is still connected.

CRs-Fixed: 440559
Change-Id: Id276dddbcebf9226e9688aa1b5dad4b281545b21
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
power: pm8921-bms: implement max current indication

It will be nice to have the BMS also report an approximate max current
that can be drawn from a battery before it falls below the cutoff
voltage. This value can be estimated by calculating the voltage
delta between noload voltage(ocv) and the lowest voltage allowed
(cutoff). Dividing this voltage delta by the estimated resistance
gives us the max current the battery can provide, above which the
battery will likely dip below the cutoff voltage.

The open circuit voltage estimate and the battery resistance
that help in calculate the max current are available when state of
charge (SOC) is being calculated.  So, calculate and save the max current
every time SOC is calculated and report this value via a public api.

This max current is used in the Battery Current Limiting (BCL) driver.
Consequently, remove the api that returns battery resistance and
clean up the charger driver from calculating the max current.

Change-Id: I8882575084eefa6a23bd59b8d2a54a53d793298e
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: Relax UUC delta restriction based on time

Previously, the Unusuable Charge calculation was restricted
to changing by 1% every time it was recalculated in order to
meet linearity demands.

However, if the phone is asleep, it might take much longer
than 20 seconds for the UUC to be recalculated, in which it
could have drifted a lot more than 1% due to temperature
changes.

Fix this by allowing UUC to change by an additional 1% for
every 60 real seconds between successive UUC calculations.

Change-Id: Ic1e7cf4da4d2bf73d889aee7bac6cf260b26d532
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: pm8921-bms: set minimum average current for UUC

The current code accepts a very low current value when UUC is
calculated. This causes the UUC value to stay very low when the
phone is left idle. This is also the cause that prevents SOC
from going low as the temperature decreases.

Set the minimum average current to 250mA.

Change-Id: I472b9da10e9f45b3c254f8440526f3f9d5116931
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: fix issues with reading 0 for OCV

There are cases when the OCV value in the register is 0. Most likely
the pmic did not go through a PON sequence or it was disabled while
PON happened.

There are couple of issues with reading 0 in the OCV register
- The driver jumps to end of charge condition when the register read is 0.
- The driver assumes that it never took an OCV and behaves as if it is
  reading the PON OCV on every calculation. Since it sees a value of 0,
  it estimates OCV on every calculation.

Fix this case by initializing ocv_reading_at_100 and
prev_last_good_ocv_raw to an impossibly high value to differentiate
it from the 0 OCV case.

Change-Id: I1560e0df1c89be1db1e1d1aeaaeef2e6da5f85c1
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-charger: fix sub revision check

Rather than checking for the value 1 check that
bit zero is set.

Change-Id: Ie2842b28648084d8970329d7c76fcf0d0666a847
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-charger: change pr_err to pr_debug for usb trim

When reverse boost workaround is happening, the driver changes the
amount of current to be drawn from the USB. This results in printing
a lot of trim related messages. These messages should really be
debug messages and not error messages as they appear currently.

Fix them.

Change-Id: I2dccaedb559fc5e9865b137f980024e068bdafa3
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-charger: Identify supply type based on USB charger type

Use USB charger type to determine if the power supply is of type MAINS
or USB. This makes sure that the supply type is identified only after
the USB driver has detected the charger type.

CRs-Fixed: 421460
Change-Id: I61a3d44f81d829f1ef22fd3044c65e4b3518b92b
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Revert "power: pm8921-charger: change BOOT_DONE configuration"

This reverts commit b157ff75f967cc72c51f6eae3feaa6ba7a432c87.

Enabling BOOT_TIMER may cause an inadvertent shutdown in the subsequent
boot cycle for certain valid scenarios. Do not enable this bit.

CRs-Fixed: 434578
Change-Id: I0d657c2e0d47af32cc35cd66b902be72952e5438
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
power: pm8xxx-ccadc: protect calibration with a mutex

Bad calibration values was observed when the calibration routine is run
simultaneously with itself. This is most likely because the ccadc
switched channels while taking samples.

Protect the calibration function with a mutex.

CRs-Fixed: 444218
Change-Id: I1bb841e463658c8db42eb15ecc1687262df86a2f
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: implement BMS reset

Sometimes during testing it is convenient to force the BMS to take a new
OCV, essentially restarting the BMS soc calculation in order to test
short portions of the battery profile.

Implement a BMS_reset module parameter, which sets OCV to the
instantaneous VBAT and resets the coulomb counter whenever a 'Y' is
written to it.

Furthermore, in the bms reset mode, keep UUC constant at 3%, and do not
run adjusting algorithms until a 'N' is written to the module parameter.

Note that this feature should only be used with a fake battery, as it
maintains a constant voltage and gives us near true OCV estimates.
Also, the adjusting algorithm is disabled due to this reason. If
adjustments to the OCV were allowed, we will end up adjusting the SOC
higher, because the OCV est will never go low as the battery discharges.
It will fail the test cases for which this feature is designed.

Change-Id: Idfe7f0edf9c25f018f6e6d0a9df20a1a04d5277a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: disable ocv updates for flat portion of the curve

An issue is observed when an OCV is updated while the device is
sleeping. When it wakes up the SOC calculations are run on the new OCV
which result in a drastically different SOC than previously reported.
The root cause of this issue is PON OCV likely was unsettled.

Provide a feature where OCV updates can be disabled between certain
SOC range.

Change-Id: I54a75a7e9d05ff2c8ccd484850f02a0190d6a3b7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: fix override mode causes sleep current increase

The override mode is used to measure battery voltage and current
simultaneously. We observed that the XOADC and the AMUX
were left enabled even after the override mode is exited. This
causes the current consumption to increase by 500uA.

Execute a dummy XOADC read after override mode is exited. This will
ensure that the XOADC and the AMUX get turned off after the dummy
transaction is completed.

CRs-Fixed: 440864
Change-Id: I53b8b67d55bbab1de588a36b7d2eca26ba6e6bfd
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: fix the mismatch of container_of member type

Use the correct member type 'struct delayed_work *', instead of
'struct work *', for the container 'struct pm8921_bms_chip *'.

Change-Id: Ifcc03472626916076c1d9a24d8f2dc2d6b61b0d2
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
power: pm8921-charger: Support multiple vbus requests

ACA chargers can generate multiple vbus current draw requests
based on the number of USB peripherals connected to the dock.
Handle this by allowing runtime modification to the max target
current limit.

CRs-Fixed: 427933
Change-Id: Ie508a85bbbe129d77af48c05235376779d799128
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
power: pm8921-charger: don't apply kickstart unless it is 8921 pmic

The current driver applies the kickstart routine in probe regardless of
the pmic variant. The kickstart is only required for 8921 pmic.
Fix this.

Change-Id: Ibe48766663e60f0a4febef983d97bb6e5370ea1a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: Enable batt alarm

Set the batt alarm to wake up the system if the
battery voltage falls below a threshold. This is to
make sure that the device does not shutdown abruptly
without any notification.

Hold the low voltage wakelock to prevent the device
from going to sleep immediately after the low voltage
notification.

Change-Id: Ifaeeeb27bd85f9c95f026ac3565681432e247b02
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
ASoC: msm: Fix delay in switching from WFD session

- When a running WFD session is paused/disconnected, there is
  a delay of about 10-15 seconds in switching audio from WFD
  sink to target.
- pcm_write is blocked because pausing/disconnecting the WFD
  session closes the backend DAI before a new link is established.
- Avoid closing afe if front end PCM session is still active.

CRs-Fixed: 444163
CRs-Fixed: 425512
Change-Id: I1ad6de1e201aa6130c397007219c0d370c7be2a1
Signed-off-by: Satya Krishna Pindiproli <satyak@codeaurora.org>

Conflicts:

	sound/soc/msm/qdsp6/q6afe.c

Signed-off-by: Vivek Panwar <vpanwa@codeaurora.org>
mmc: msm_sdcc: don't poll for TX/RX active if haven't waited for prog_done

Few data write commands (like CMD24 (Single Block Write) or ACMD25)
don't have the stop command (CMD12) and in such cases, if the controller
don't support the AUTO_PROG_DONE feature then we may complete the
request having the DAT0 still showing the BUSY status. In such cases,
TX/RX ACTIVE status bits would remain set until the DAT0 status is
changed from busy to ready.

With this change, we are not polling for TX/RX active for above
mentioned cases but reset the DPSM so that we don't end up polling
for TX/RX ACTIVE status for next command (which is generally a status
command).

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

Conflicts:

	drivers/mmc/host/msm_sdcc.c

(cherry picked from commit bfbe58adfe36f2b01333667703d9d8d7a06fa06b)

Change-Id: Ib1f33900a2a1dd09190c92caeb51b421f17c08b3
Signed-off-by: Maya Erez <merez@codeaurora.org>
mmc: msm_sdcc: don't perform busy wait for CMD13 (status command)

Currently SDCC driver is waiting for the PROG_DONE interrupt after
sending out the CMD13 to card  even if command flags doesn't indicate
so. This may cause the issue in when we try to HPI (High Priority
Interrupt) the ongoing BKOPs (Background Operations). Hence this
change removes the busy wait (PROG_DONE) for CMD13.

Change-Id: I8fb6ab4908bf1c4c5a939413d27eec29cde22f68
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit 56fd45187495f27a7f9c3ebe947c1ffc9851fffd)
(cherry picked from commit bcc40276b4effa56feee534e1eb6d7218b03ab5b)