msm: mdss: Request max register bus bandwidth for PP LUTs during resume

There are a couple postprocessing features that are LUT based features,
and they require a lot of register accesses to configure the hardware.
During the first resume display commit, when all registers are
reconfigured, if any of the LUT based PP features are enabled, then we
will request maximum bus bandwidth to speed up the accesses.

Change-Id: I17a8c0f563db3a3715c170dbcd5666b0ee567b01
Signed-off-by: Benet Clark <benetc@codeaurora.org>

ARM: dts: msm: Reading MDP offsets from device tree for PP functions.

The register address offset values are currently stored in macro
variables. These are now being moved to device tree. These addresses
cannot be calculated in cases of targets which have single DSPP like
8226.

The required register address offset values are added to the
respective target device tree files. The address validation
functions corresponding to PP are modified to read the values from
these newly added device tree entries.

8x10 target does not require this change as it uses MDP3
architecture.

Change-Id: I9387c8fadc36e3bbaceb51b243d3a9537250a3be
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>

msm: mdss: remove obsolete method of mixer register read/writes

Starting apq8084, mixer offsets have changed compared to previous
chip-sets. Some of the code is still using old method of reading
and writing to mixer registers which leads to incorrect hw programming.
Replace these mixer register read/writes with working method.

CRs-Fixed: 564273
Change-Id: I2aa1c5d24c6a1c5b89f77bd8d450c0831dd720b7
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>

msm: mdss: Fix CSC programming for VIG3 pipe

CSC programming assumes that pipe numbers are symmetric for same
type. This assumption is not valid with APQ8084 and leads to skipping
of CSC programming for VIG3 pipe. Fix this by using helper APIs to
find out if pipe is VIG or not rather than directly manipulating data
structures.

Change-Id: I130ee3994d1f5c5a96e644f8095c75d2189fbdda
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>

msm: mdss: fix bandwidth vote release for dual-dsi cmd mode panels

For dual-dsi command mode panels, bandwidth(bw) vote is supposed to be
released once ping-pong done interrupt for both controller is received.
In current implementation, if secondary ctl finishes last, which is the
case most of the times, then bw release is called using secondary ctl.
But bw is calculated/stored using main ctl because of which bw vote is
never released as expected. Fix this by releasing bw vote using main ctl.

Change-Id: Iadbd150ed6a35478da2cb376e29b01e579a526b8
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>

mdss: calculating length based on offsets from dts

If the len values are not mentioned in the device tree, then
calculate the length based on the corresponding offsets
Plus split mdss_sspp into: sspp_vig, sspp_rgb and sspp_dma.
Because in 8092, the lengths are different. Therefore, they
should be separate lengths in the generic implementation.

Change-Id: I0f83ffae15d1ae3e92a01f7f23215c94b23065c7
Signed-off-by: Zohaib Alam <zalam@codeaurora.org>

ARM: dts: msm: Removing len parameters for mdss device tree

The len parameters for sizes of SSPP, DSPP, CTL and Mixer
interfaces are not used in the code anymore.

Removing those parameters from device tree.

Change-Id: Ib49a3d79c27f3291d942e0f36fcb78da93eb43f2
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: Disable bw release for cmd mode panels

For command mode panels, driver can release the bandwidth once
the frame is transferred to the panel and no more processing is
done in the display driver; in some scenarios this results in
more power consumption since more interrupts are generated.
This change disables the bandwidth release for command mode panels
and add a debugfs node to dynamically enable the feature if needed
for debugging purposes.
To enable the bw release:
echo 1 > "<debugfs>/mdp/perf/enable_bw_release"
To disable the bw release (default):
echo 0 > "<debugfs>/mdp/perf/enable_bw_release"

Change-Id: I61670606f1cf52b8d889678e6ffe7d0e911771e7
Signed-off-by: Ingrid Gallardo <ingridg@codeaurora.org>
msm: mdss: disable bw release from rotator

For rotator path, display driver can release the rotator
bandwidth once the rotator finished processing. In some
scenarios this results in more power consumption since more
interrupts are generated to release the bandwidth.
This change disables the bandwidth release for the rotator path
and add a debugfs node to dynamically enable the feature if
needed.
To enable the bw release for rotator:
echo 1 > "<debugfs>/mdp/perf/enable_rotator_bw_release"
To disable the bw release for rotator (default):
echo 0 > "<debugfs>/mdp/perf/enable_rotator_bw_release"

Change-Id: If147b8fb202edcb389fe85e78f8d61d2a98cef95
Signed-off-by: Ingrid Gallardo <ingridg@codeaurora.org>
msm: mdss: Correct set backlight call during unblank

If brightness node is written prior to unblank by surfaceflinger
the backlight level being applied would not be correct. The
stored value is also overwritten.

Passing the correct unset backlight value during unblank.

Change-Id: I430bc759e09ecc6dfbc616af47fbc953aa542b9a
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
video: mdss: Fix a few potential NULL pointers

Change-Id: Id9b289c6b02b9bb7b793bb8c686f15c5549a62d3
msm: mdss: reset cont splash screen flag after notifying panel intf

Starting with commit a702d63198e3524740be22b66ce1933064174019, the
continuous splash screen feature flag for the secondary panel was also
disabled along with that of the primary panel. However, this should only
be done after notifying the interface drivers about the transition from
the splash screen to the boot animation. This is needed as the DSI panel
driver relies on this flag to avoid unnecessarily configuring the DSI
lanes in to the ultra low power state during this transition.

Change-Id: I59d312248c579d27913f23dc23e9c91a99549725
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
mdss: display: move mdss_mdp_irq_enable out of clk_lock scope

There are potential deadlock between irq handler and
mdss_mdp_irq_enable() since both can acquire mdss_lock
before trying to grab local lock. Add koff_lock for kickoff
related function in addition to original clk_lock which used
for clock related function to reduce unnecessary lock contention.

CRs-Fixed: 665524
Change-Id: Iebc5023eb9dc99f2a2709379bfac67ec275046a7
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: mdss: support reduced dspp and WB interfaces

MDSS driver has condition check for 1:1 mapping for dspp to
interface and WB to ctrl. This check is not valid for all MDP
version hardware.  It can support less dspp compared to number
of interfaces. It can also support less number of WB paths
compared to controllers. This change enables MDSS driver
to handle such hardware conditions.

Change-Id: Ic08e274c73cc41e80245a0d3d4ae7b854bd5a2d3
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
msm: vidc: handle dynamic buffers in pendingq during flush

In dynamic buffer mode, if flush was received before
stream-on, driver would have incremented the ref count
for output buffers, but not yet sent to firmware. So,
after flush done, there would be no fbd from firmware
and the reference to these buffers would not be removed.
So when the buffers are dequeued, driver fails to
unmap and free the output buffers.
Subsequently, after flush done, when client queues
the same output buffers again to driver, the ref
count is increased and becomes 2. This results in
the driver holding the buffers with itself, thereby
entering in to a deadlock situation and starving the
firmware of output buffers. This results in a video
freeze.

Change-Id: I0c3d13124bd48b900e56e14666eaed2f0e7ee9d6
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: msm_bus: Fix inadvertent stomp on BKE_EN register

While setting the QoS mode of fixed mode masters bad masking
operations is causing accidental stomp on the upper nibble of the
BKE_EN register.

Change-Id: I5675e1dbc6fd5a01faac49c903e12a9c95e32254
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
msm: mdss: reset runtime status upon device resume

MDSS is power-collapsed in idle screen cases using the pm runtime
framework. However, it is possible that the runtime PM status may
not match with the post-system sleep status when the device is
resumed. This sometimes leads to the inconsistencies in MDSS
idle-power collapse upon system resume. To address this issue,
reset the runtime PM status in the pm resume handler.

Change-Id: I5696ce6c154f2898b82e70119d3d9a2be79b59b7
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: refactor MDSS idle power collapse logic

MDSS GDSC can be turned off, or power-collased for command mode panels
in static screen use-cases. In the current implementation, the power
collapse is triggered by a worker thread in the interface driver
whenever once it enters the idle state. However, MDP driver already
registers pm_runtime callbacks for idle and suspend notifications and
also maintains a count of active overlay sessions. It is much simpler
and cleaner to trigger idle-power collapse based on that. This also
avoids unnecessary synchronization issues pertaining to the power
collapse worker thread.

Change-Id: I198e6d7685e5ef6eed7cd06a77fa76435940b805
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
wcnss: Reduce the pil_retry count value

wcnss driver doing multiple pil retry which causing boot process
block upto all pil retry finish. reduce the pil retry count so
it will not delay other boot process.

Change-Id: I753e5d381a3559eaee30fddd50ecc65a30815f64
CRs-Fixed: 688990
Signed-off-by: Hardik Kantilal Patel <hkpatel@codeaurora.org>
regulator: Add proxy consumer driver

Add a proxy consumer driver which can be used to ensure that a
given regulator maintains a certain minimum state during bootup.
Enable state, voltage, and current may be forced to specified
levels.

Change-Id: I0ccc63a41684462684ac737fb2f4129a3e6e4aea
Signed-off-by: David Collins <collinsd@codeaurora.org>
regulator: Call proxy-consumer functions for each regulator registered

Add a call to regulator_proxy_consumer_register() at the end of
regulator_register() and a call to
regulator_proxy_consumer_unregister() at the beginning of
regulator_unregister().  These calls ensure that proxy consumer
features may be used by any type of regulator regardless of the
driver supporting it.

Change-Id: Ia70da1df47042fa673c42f389136557f868d19a3
Signed-off-by: David Collins <collinsd@codeaurora.org>
ARM: dts: msm: Add proxy consumer properties for regulators on msm8974

Add regulator proxy consumer properties for the regulators used
by clocks on msm8974 and msm8974pro targets:

     supply     msm8974            msm8974pro
1. vdd_dig    pm8841_s2_corner  pma8084_s2_corner
2. vdd_mem    pm8841_s1_ao      pma8084_s1_ao
3. vdd_hfpll  pm8941_l12        pma8084_l12

Use proxy consumers to ensure that each of these regulators is
kept on during boot-up at the highest allowed voltage.  This
guarantees that any hardware set up by bootloaders at non-minimum
regulator voltage will continue to operate until the driver
responsible for the hardware has initialized and made its own
regulator requests.

Change-Id: Ib7f0356acf3c6625552ef09c888835b749da5d88
Signed-off-by: David Collins <collinsd@codeaurora.org>
defconfig: msm8974: Enable proxy consumer driver

Enable the proxy consumer driver so that regulators may be
kept at a certain minimum level during boot.

Change-Id: Icb014f388dcacb482e17785ec704bfa94f4f44b0
Signed-off-by: David Collins <collinsd@codeaurora.org>
ARM: dts: msm: use a corner regulator for wcnss VDD_CX on all boards

Update wcnss nodes to use voltage corner regulators for VDD_CX on MSM8226,
MSM8610, MSM8974, and MSM8974Pro.

Also update the wcnss platform driver to use voltage corner values for the
VDD_CX regulator supply.

Change-Id: I766b5e15bfdb0c68011fd2a27886026f754bdefd
Signed-off-by: Yue Ma <yuem@codeaurora.org>
msm: krait-regulator: add support for auto mode

On certain PMIC the AUTO mode for the ganged regulator operates
within spec. Allow the driver to use the auto mode and skip
controlling  PFM/PWM mode switching.

Enable support for using auto mode configuration.

Change-Id: Id4b0b39e0022496844a5f5bc1a37e4795ddd9c5b
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
msm: krait-regulator: auto mode workarounds for pm8841

On pm8841 before enabling automode set the pwm current limit to
2Amps and reset it back to 3.5Amps after disabling automode.
This helps prevent overshoot when pfm-pwm switch happens while
running in auto mode.

Change-Id: I001c1aa649d7eed629e48cbb6d97194681e43d1b
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>