dt: introduce of_get_child_by_name to get child node by name

This patch introduces of_get_child_by_name function to get a child node
by its name in a given parent node.

Without this patch each driver code has to iterate the parent and do
a string compare, However having of_get_child_by_name libary function would
avoid code duplication, errors and is more convenient.

Change-Id: Id33184bb9f4b494e7121d7dde719d29206dcad52
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
video: mdss: Squash MDSS power collapse feature

mdss:display: add regulator control to dsi-1

Regulators are shared by both dsi controller. For both
dual and split display application regulator should be
controlled individually to avoid reualtors are turned off
while dsi-1 still running which cause DLB0_ERR_CONTENTION_LP1
error.

CRs-fixed: 579900
Change-Id: Ia29bd3e49a405ccb1ad55f08f3897cee2ff6f4c6
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

msm: mdss: dsi: Add ULPS mode support for dual dsi configuration

For dual dsi panels with broadcast mode enabled, the two dsi
controllers work in a master-slave configuration. Add support for
enabling ultra low power state (ULPS) mode in this use case.

Change-Id: I9e4383ca60174d6ffa599ce6caa47676a5eea216
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>

msm: mdss: Organize regulator supplies used by DSI controller

Regulator supplies in the DSI driver are used for two different
purposes. One set of regulators is used as a supply for the DSI
controller while another set is used to supply voltage to the
panel attached to the DSI controller. To support advanced power
saving features, it is required to be able to power down just the
DSI controller while keeping the panel on. To enable this,
organize the supplies into logical power modules.

Change-Id: I54f3ccba1c5ad1fe5c66e8700a012d22ab2684d6
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
(cherry picked from commit 855df197babeaa2ed2090622548d7f3f8b6e798a)

ARM: dts: msm: add mdss gdsc supply to dsi controller device

It is possible for the DSI controller to be active when MDP is
power collapsed. DSI controller needs to have it's own vote for
mdss gdsc to ensure that gdsc remains on in such cases.

Change-Id: I37f98c6e4f6d30908373b812fc50e29ba001b752
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>

msm: mdss: add support to enable idle power collapse

Add support for a new configuration entry to enable mdss power
collapse for idle screen use-cases, when a command mode interface is
active. Currently idle power collapse happens only if the Ultra-Low
Power State feature of the DSI controller is enabled. Adding a separate
configuration entry provides the flexibility to enable this feature
independent of the state of the DSI controller.

Change-Id: I4732a95a9f3d0db3e7ecc96a36414349ac6b5604
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
(cherry picked from commit 56758b2157a564b4022f29dcd56049fad15005fc)

mdss: mdp: do not send panel events for idle power collapse

When mdss idle power collapse is enabled, panel suspend and resume
events should not be sent to ensure that panel drivers remain active.

Change-Id: Ifbcdee69432cbd0d30f16c86af9c126d9443e269
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
(cherry picked from commit 8fe98249f7c1783eff001d91eb1f236a1f950270)

msm: mdss: move ULPS configuration to DSI clock control

DSI Ultra Low Power State (ULPS) mode is property of the DSI data
and clock lanes. Current implementation requires the MDP command
interface to send explicit events to the DSI controller to config
ULPS mode. However, it would be a lot more efficient if the DSI
controller would independently decide to enter/exit ULPS based on
whether the link clocks are enabled or not. This also ensures that
if any DCS commands need to be sent when ULPS is enabled, the DSI
controllers will exit ULPS accordingly.

Change-Id: If8d5b7039b5e104bcee5304c7c0ddb3cdd5bbcbc
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
(cherry picked from commit 1261aee15c058579c0a8b4492ce08285ef07fa03)

msm: mdss: modify MDSS idle power collapse exit sequence

When MDSS is idle power-collapsed, any events that require hardware
programming should result in exiting idle power collapse. Currently,
this is only done whenever a screen udpate happens. However, it is
possible that other APIs may be called prior to the actual screen
update. To address these cases, add the exit sequence call at the
interface level as well.

Change-Id: I162e1c1c4137a2ba20ed0b76f0c182c2c931cc87
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
(cherry picked from commit 200640f0be2beba654003c5b75fbbe3eab8a2d9c)

msm: mdss: Add support to read DSI clamp offset from DT

Since the DSI ULPS clamping registers offset varies
from chipset to chipset, so read the offset values from
chipset specific mdss dtsi file.

Change-Id: I0dcdf8cf0d0f3f1851337e05add833fbdac0632c
Signed-off-by: Sandeep Panda <spanda@codeaurora.org>

msm: mdss: dsi: enable idle power collapse without DSI ULPS

It is possible to power collaps MDSS without configuring the DSI
lanes in Ultra Low Power State (ULPS). Add support for this by
configuring DSI clamps irrespective of whether ULPS feature is
enabled or not.

Change-Id: I0564216737cc6e98c1e8658862cf7af5dabd363c
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>

msm: mdss: fix race condition of DSI off and status check.

fb_event_callback cancels the work queue when it receives
the power down event. However, this event occurs after the
panel & DSI have been turned off. So if the check_status
function was being called right when the panel is being
turned off, we have a race conditon. Hence add offlock
mutex to ensure that bta status check is done when dsi
is being turned off.

Change-Id: Ie341c002c4544376bda2940fa65c6eb13997ae17
Signed-off-by: Vineet Bajaj <vbajaj@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: I96ee339b96ad794b2d87d19d1c14768fca3fa192
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>

video: mdss: Fixup power collapse

Change-Id: Iaf58e785e86c994b25001e6589162ba5c3043abc

mdss: mdp: start vreg release index from PANEL_PM

Start vreg release index from PANEL_PM to avoid
release call with DSI_MAX_PM in error case. This
avoids crash in dsi_probe if panel node parsing fails.

Change-Id: I236f40851d41831fe37eea77aa83e2f4ce031a3b
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>

video: mdss: Fix control of batfet regulator

Change-Id: I4b88a83e3c7caf1c1f5c57005731a05d05c774c8

msm: mdss: fix handling of runtime pm ref counts for fb device

In the current implementation, pm runtime status for the framebuffer
device changes to active when the overlay session is started. With idle
power collapse feature enabled, it is possible that the MDSS core could
be turned off prior to starting the overlay session depending on the
duration of the idle timeout. This may result in an invalid hardware
configuration leading to various target instabilities. Fix this by
holding a reference to the pm runtime when mdp overlay is turned on.
Similarly, when the userspace process is killed, wake up MDSS from idle
power collapse before shutting down the fb device.

Change-Id: Ie7748732fe76f9b2766da32b972e1e9fe7ff8751
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>

video: mdss: Fix another unbalanced clock ctrl

Change-Id: Ia993ab7532197f94e400f34df989d7d576a11552

Revert "msm: mdss: handle get buffer failure gracefully"

 * It's possible in the split rotator case for the rotator to
   get queued with has_buf = 0, which results in solidfill being
   enabled on the pipe. This is leads to IOMMU page faults and
   writeback timeouts.
 * Fixes green screen when rotating video on dual-DSI, and 4K
   video rotation on single-DSI (split rotator).

This reverts commit e092ab6793d4c718a37da38f79bb9d79c92c22c8.

Change-Id: I6cd57bba4be77242c2e314a5c0452eae1f10b104
a0001: Correct truly panel on commands, add gamma commands

Change-Id: Id38f4f5c7ad70478fbe283606359aae72c9cdd2e
a0001: Update truly panel DTSI for MDSS changes

Change-Id: Ic1bdd095e27f4d13c64a6b1e5c0ad8f125de2481