power: bms/ccadc: move ccadc calibration to ccadc driver

There is a dependency for the CCADC calibration work on the BMS
driver. This prevents some devices that do not use the BMS
to utilize the CCADC.

Remove this dependency by moving the ccadc calibration
work to the CCADC driver to avoid this.

Change-Id: If43c781d6d2bc27f64dbbe594b6e81c5a5642f0b
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-bms: remember soc between restarts

Currently the code does not have a mechanism to remember the soc
reported just before shutting down and upon restarting the new
soc reported is off from the previous soc value reported.

This change introduces
- a method to save soc in an unused coincell back register: ssbi address
  0x107 is not used on 8921 and serves the purpose of storing the soc.
  The driver reads this value and uses it to scale the reported soc.
- a method to detect that a battery was removed and perhaps replaced by a
  different one. If the battery is found replaced the driver is notified
  of the change and it disregards the soc value it read from the backup
  register. The charger driver has a battery backed bit (force vref
  therm) which it sets in its initialization sequence. Once set the
  value remains between restarts, unless the battery is removed. The
  default value of this bit is 0. Hence if a zero is detected before
  writing to it, battery was removed between restarts - this mechanism
  is used to notify the BMS to disregard the soc read from the backup
  register.

Note that for this to work correctly the bootloader needs to be updated to
not overwrite register 0x107 upon restart.

CRs-Fixed: 370287
Change-Id: If7d098552d36eb27a396ee7d37f78d3629861f6e
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8xxx-ccadc: remove support for pm8921 v1.0 and v1.1

This ccadc module is reused in multiple pmics. It is now unnecessary
to check for 8921 versions in the driver. As a result of this change
older 8921 versions are not supported.

CRs-Fixed: 372679
Change-Id: I2114f9428e2ba1a29c2bc9caaaa75106caf1dfc3
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: remove support for pm8921 v1.0 and v1.1

The bms module is reused in multiple pmics. It is now unnecessary
to check for 8921 versions in the driver. As a result of this change
older 8921 versions are not supported.

CRs-Fixed: 372679
Change-Id: Ie9131d47ed08fa6fa39812c9e60be34cc6280e4c
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
msm: camera: Fixed VPE crash issue.

Check if VPE base has been unmapped before accessing VPE h/w registers.

Change-Id: I5457612902a3382df4e776ee726f030272c7b731
CRs-Fixed: 390332

Signed-off-by: Chandan Gera <cgera@codeaurora.org>
Bluetooth: fix shutdown on SCO sockets

shutdown should wait for SCO link to be properly disconnected before
detroying the socket, otherwise an application using the socket may
assume link is properly disconnected before it really happens which
can be a problem when e.g synchronizing profile switch.

Signed-off-by: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
(cherry picked from commit 2e02b861173406a1287a53ca7b836a4ad5fd4255)

Change-Id: I30a63c5898eff1b0d18673303c4a87f35e286253
CRs-fixed: 365445
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
power: pm8921-charger: Bound lower AICL limit at 500 mA

AICL is only relevant for wall chargers for current
ratings above 500 mA. Once the minimum value is reached
stop decreasing the IUSB_MAX value to avoid a complete
charging stop by setting IUSB_MAX to 100 mA.

Change-Id: I9b100a5a06aa22552ba8251ce4137e69aea7d07c
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Bluetooth: Validate session before rfcomm_session_del

In rfcomm_session_put API the session count is decremented
and when it is equal to zero rfcomm_session_del is called
where session is removed from sessions list and freed. The
current change is verify the existance of session in list
before acting session. The avoids the possibility of action
on a deleted session, which causes crash.

CRs-Fixed: 383000
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
(cherry picked from commit ff724cc3a2f52f1190b28c56b28bdb16e6613ad4)

Change-Id: Iebfdd9789ed20537aa6e57a1611688dbb0bfda66
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Bluetooth: Avoid race condition between hci registration/un-registration

Syncronized hci device registration/un-registration to avoid race
condition when called from mutiple paths/scenarios concurrently.

CRs-fixed: 375287
Signed-off-by: Bhasker Neti <bneti@codeaurora.org>
(cherry picked from commit 6d353eea1df6995cf2d7619547b203479b20e3bc)

Change-Id: Id8f577eb16e77811d62098e7dca4d9147616f71c
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:
	drivers/bluetooth/hci_smd.c
ARM: 7382/1: mm: truncate memory banks to fit in 4GB space for classic MMU

If a bank of memory spanning the 4GB boundary is added on a !CONFIG_LPAE
kernel then we will hang early during boot since the memory bank will
have wrapped around to zero.

This patch truncates memory banks for !LPAE configurations when the end
address is not representable in 32 bits.

Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit b5b28874153adc2dc8fda9d6854bb011e6752952)

Change-Id: I2c483e3d43ffd8269dc9247934945ef4e1d52b6b
CRs-fixed: 355203
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Bluetooth: Block SCO disconnect operation on BT_CLOSED state.

Have maximum blocking time for shutdown operation as DISCONNECT_TIMEOUT.
During this period when SCO connection closes, the userspace will be
updated on the close operation. Existing approach of immidiate return
on shutdown call can cause synchronization issues on SCO state between
kernel and userspace. This happens when disconnect operation takes
more time at kernel space.

CRs-fixed: 365445
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
(cherry picked from commit f799996e309cad545b3a7f84ef6f333a09c8b876)

Change-Id: If398b1d14f62af498c3653bfa13a0344ec52b769
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
ASoC: msm: Reset the calibration block after subsystem restart

    - After sub system restart ACDB cannot push data to Q6
    - Memory map is not happening after sub system restart, because
      the calibration block address is same as the cached address.
      Without memory map calibration block is sent to DSP, where it is
      failing with memory map error.
    - Reset the calibration block after sub system restart, so that
      memory map happens after sub system restart.

CRs-Fixed: 389214
Signed-off-by: Deepa Madiregama <dmadireg@codeaurora.org>
(cherry picked from commit b71818e0ee674b2357d419c6559b5aa009d96a14)

Change-Id: I9046d124b2789eef33ff5c356ea52e96bb09f5db
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
radio-tavarua: Validate whether the current station is good or bad

Provide mechanism to decide whether the currently tuned station
is valid or not.

CRs-Fixed: 371689
Signed-off-by: Anantha Krishnan <ananthk@codeaurora.org>
(cherry picked from commit 4c2dcd4a4cec5939fffda43f162c04757fdba42c)

Change-Id: I95d34c1e952088bc0648a047399f31c4d5f7f63a
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
mmc: core: add eMMC hardware reset support

eMMC's may have a hardware reset line.  This patch provides a
host controller operation to implement hardware reset and
a function to reset and reinitialize the card.  Also, for MMC,
the reset is always performed before initialization.

The host must set the new host capability MMC_CAP_HW_RESET
to enable hardware reset.

Change-Id: I52f27758232200182311a883c0c0f1fe7bdca29a
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
msm: kgsl: Update pagetable on context destruction for A20x

Ensure that pagetable is updated during context destruction. This
resolves stability issues during Camera launch/exit scenarios. Applies
only to A20x GPUs. This change is already done for Z180 device.

Change-Id: I955c7220aa8234009f5bca0a273093e47147279d
Signed-off-by: Rammohan Basavaraju <rammoh@codeaurora.org>
Bluetooth: Send Disconnection reason to Bluez

Send device disconnection reason to bluez on receiving the
diconnection complete event so that low energy profiles
such as proximity can decide to reconnect if the reason
is link loss.

CRs-Fixed: 378240
Signed-off-by: Archana Ramachandran <archanar@codeaurora.org>
(cherry picked from commit da09d26a75ee1c7c1911dcfbe0128fd09f6631f4)

Change-Id: I4c1ec29e4b6c73e4376c9f7cac12e44df7a05699
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
mmc: block: add eMMC hardware reset support

For cards that support hardware reset (just eMMC), try a reset and
retry before returning an I/O error.  However this is not done for
ECC errors and is never done twice for the same operation type
(READ, WRITE, DISCARD, SECURE DISCARD) until that type of operation
again succeeds.

Change-Id: I2683983102dc6fe9c76fccc24466f8c6a41560a5
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
[asutoshd@codeaurora.org: Fixed merge conflicts]
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
mmc: core: power-cycle sd card on error

Hardware reset is not implemented in SD card. To circumvent this,
a power-cycle is issued to the card & it is reinitialized.
This would help recovering from 'card stuck in programming state'
situations.

mmc_can_reset:	Added check for SD card.

CRs-fixed: 375869
Change-Id: I8bd7dc071f3569898371d5becca06ec2fe937d4a
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
mmc: msm_sdcc: Added hardware reset functionality for SD cards

In error situations, sometimes the card doesn't respond to commands.
To recover from such situations, a power-cycle is issued to the card
and it is reinitialized.

msmsdcc_hw_reset:	Defined in mmc host operations 'hw_reset'.
			This function power-cycles the card.

CRs-fixed: 375869
Change-Id: I2b02649ae3befe700a7a2401b93eb69c8014a4ce
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
ASoc: msm: Multi channel AAC clips don't play

Send channel mapping command to DSP; This command
is used to identify the output PCM buffers's
upsampling/downsampling sequence.

CRs-fixed: 351804
CRs-fixed: 351817 392479
Signed-off-by: Swaminathan Sathappan <Swami@codeaurora.org>
(cherry picked from commit 6f53088ba27a28dc4b894180695538dfffaa7ef7)

Change-Id: I7e5792e07ad35ae33137d8cf0e2644449960ebab
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>