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>
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>
msm: mdss: abstract the dsi command utility API

The dsi command parsing and construction functionalities
are hardware independent.  This is to abstract these
utility API, so that it can be shared with different versions
of  dsi host controllers.

Change-Id: I8481d9fd21e5eacc4542c72c064fa37d7fd3a11b
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: use the common dsi utility api

There are two separate dsi host controller drivers currently.
While the h/w specific operations are different, the dsi
command utility functions can be shared as that is purely s/w.
This change is to use the common dsi command utility api.

Change-Id: I381eb6dee80a88e0d4ea17a18fa030df7d13db8c
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: use the dsi panel API for sending init commands

The dsi panel driver implements the dsi command send
and receive functions.  However, on 8x10, it was using
its own version.  This change is to use the functions
defined in the panel driver.

Change-Id: I4dcec67fecb51f02b65ee7818ccbe7729f3e6831
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: update the dsi interrupt handling on 8x10

The previous dsi interrupt handling logic was scattered
in a few places.  This is to centralize the interrupt
handling logic.

Change-Id: If89a45d80a2e3523368a37d96f1d226c443e1f61
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: fix the dsi dma transaction time out on 8x10

The dsi dma data is sent during the blanking period for
the dsi video mode panel.  If the dma data are triggered
at the end of blank period, it can be in conflict with
the next video data, causing dsi controller to freeze.
This change is to trigger the dma data during the active
region, so it has enough time to be sent during the next
blank region.

Change-Id: I416bb9f82304063b802aa7f5ff09008dfdf0e6bc
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: turn on the dsi clocks before sending dsi commands

The dsi clocks can be turned off after a period of screen
idle time.  Before sending the dsi commands, we need to
make sure the dsi clocks are on.

Change-Id: Idc5c803aa6eb55d1739441d1bd395fed5c2d74c7
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
power: qpnp-bms: disable sw_cc_thresh interrupt after it fires

Currently in the BMS driver, when the software coulomb counter threshold
is reached, only a soc recalculation is scheduled in the irq handler.
This can cause issues where the BMS hardware fires another sw_cc_thresh
irq because the coulomb counter is still over threshold.

Instead, disable the sw_cc_thresh irq when it is handled and renable it
after adjusting the software coulomb counter threshold registers.

Change-Id: I70791fdae1835c8d24b7c045831d22fe86e83fdb
Signed-off-by: Xiaozhe Shi <xiaozhes@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>
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>
ARM: dts: msm: change emmc clock line drive strength

The clock line drive strength for eMMC should be 16 mA for msm8974pro-ab
mtp platform. If it is set to any other value for this platform, it can
lead to CRC errors.

CRs-Fixed: 569409
Change-Id: I717c9b895d231148b4b9522b63fb3642c956bdf8
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
Merge "msm: mdss: Document mdss driver parameters"
Merge "msm: mdss: Enable solid fill on pipe"
power: qpnp-charger: allow vinmin to be lowered to 4.0 V

Currently the minimum input voltage is limited to a minimum
value of 4.2 V. Some chargers in combination with cables
having high resistance may require the input voltage minum
to be lower than 4.2.

Fix this by allowing up to 4.0 V for the minimum input voltage
settings.

Change-Id: I6f1dfa2453c7b95ecc2ccdf2aac23981c0e4dd0a
CRs-Fixed: 584999
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
idr: fix a subtle bug in idr_get_next()

The iteration logic of idr_get_next() is borrowed mostly verbatim from
idr_for_each().  It walks down the tree looking for the slot matching
the current ID.  If the matching slot is not found, the ID is
incremented by the distance of single slot at the given level and
repeats.

The implementation assumes that during the whole iteration id is aligned
to the layer boundaries of the level closest to the leaf, which is true
for all iterations starting from zero or an existing element and thus is
fine for idr_for_each().

However, idr_get_next() may be given any point and if the starting id
hits in the middle of a non-existent layer, increment to the next layer
will end up skipping the same offset into it.  For example, an IDR with
IDs filled between [64, 127] would look like the following.

          [  0  64 ... ]
       /----/   |
       |        |
      NULL    [ 64 ... 127 ]

If idr_get_next() is called with 63 as the starting point, it will try
to follow down the pointer from 0.  As it is NULL, it will then try to
proceed to the next slot in the same level by adding the slot distance
at that level which is 64 - making the next try 127.  It goes around the
loop and finds and returns 127 skipping [64, 126].

Note that this bug also triggers in idr_for_each_entry() loop which
deletes during iteration as deletions can make layers go away leaving
the iteration with unaligned ID into missing layers.

Fix it by ensuring proceeding to the next slot doesn't carry over the
unaligned offset - ie.  use round_up(id + 1, slot_distance) instead of
id += slot_distance.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: David Teigland <teigland@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Change-Id: Ifb6d64747e7f08e2f5d7609bd66a48405f0c9b95
Signed-off-by: Prakash Kamliya <pkamliya@codeaurora.org>
Merge "power: qpnp-bms: disable sw_cc_thresh interrupt after it fires"
Merge "msm: clock-nfc: fix clock voting to keep BBCLK2 on durring idle mode power collapse"
Merge "msm: mdss: Change wait_for_completion to timeout in MDSS DSI driver"
Merge "msm: vidc: Fix handling of ocmem_notifier_register() return value"