OMAPDSS: HDMI: Move GPIO handling to HDMI driver

We currently manage HDMI GPIOs in the board files via
platform_enable/disable calls. This won't work with device tree, and in
any case the correct place to manage the GPIOs is in the HDMI driver.

This patch moves the handling of the GPIOs to the HDMI driver. The GPIO
handling is moved to the common hdmi.c file, and this probably needs to
be revisited when adding OMAP5 HDMI support to see if the GPIO handling
needs to be moved to IP specific files.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Backport-by: Roger Quadros <rogerq@ti.com>
OMAPDSS: HDMI: Get HPD interrupts to work on HDMI cable connect

The TPD12S015A HDMI interface chip needs CT_CP_HPD gpio to be enabled
so that 5V supply is available for HPD detection to work.

Keeping CT_CP_HPD always high has a small impact on power. About 30uA@3.3V
vs 1uA@3.3V when it is low.

Signed-off-by: Roger Quadros <rogerq@ti.com>
OMAPDSS: HDMI: Fix potential NULL ptr dereference and L3 errors

The HDMI IRQ handler needs to check if the irq handler hooks are
valid before calling them to prevent NULL pointer dereference.
We also need to use runtime_get/put() around the functions accessing
HDMI registers else we would get L3 bus errors.

Signed-off-by: Roger Quadros <rogerq@ti.com>
OMAPDSS: Add notifier chain for event notification

Users like OMAPDRM would be interested in events like
Hotplug connect/disconnect. We support this be creating
a event notifier chain. Subscribers can register/unregister
to the OMAPDSS event notifier by using omap_dss_add_event_notify()/
omap_dss_remove_event_notify().

Low level code can publish the event by using dss_notify().

Signed-off-by: Roger Quadros <rogerq@ti.com>
omapdrm/OMAPDSS: get rid of omapdrm_hpd_change()

We no longer need this as we will use the DSS event
notifier call chain for hotplug events.

Signed-off-by: Roger Quadros <rogerq@ti.com>
OMAPDSS: HDMI: Handle HDMI hotplug and notify subscribers

Handling GPIO based HPD is the same irrespective of HDMI IP so
it makes sense to have this piece of code in hdmi.c instead
of hdmi_ip_xxx.c.

Signed-off-by: Roger Quadros <rogerq@ti.com>
omapdrm: service the omapdss hotplug event

Now that omapdss publishes hotplug events we can
subscribe to it using omap_dss_add_event_notify()
and make hotplug detection work.

This patch should get HDMI display to work as soon as it
is plugged in. Previously we had to wait a maximum of
10 seconds for the HDMI panel to be probed.

Signed-off-by: Roger Quadros <rogerq@ti.com>
OMAPDSS: HDMI: disable HPD interrupt on system suspend

This patch fixes the following error in this test case

-Boot with HDMI disconnected
-suspend the system
-connect HDMI monitor while system is suspended

[  214.363311] omapdss CORE: suspend 2
[  214.374176] PM: suspend of devices complete after 64.697 msecs
[  214.380889] PM: late suspend of devices complete after 0.427 msecs
[  214.388763] PM: noirq suspend of devices complete after 1.190 msecs
[  214.395538] Disabling non-boot CPUs ...
[  214.409088] CPU1: shutdown
[  217.305999] Powerdomain (core_pwrdm) didn't enter target state 1 Vs achieved state 3.
[  217.306030] current state 3
[  217.317413] Powerdomain (l4per_pwrdm) didn't enter target state 1 Vs achieved state 3.
[  217.317413] current state 3
[  217.328857] Could not enter target state in pm_suspend
[  217.334625] Enabling non-boot CPUs ...
[  217.355346] CPU1: Booted secondary processor
[  217.355438] CPU1: Unknown IPI message 0x1
[  217.364898] CPU1 is up
[  217.368469] PM: noirq resume of devices complete after 1.037 msecs
[  217.375396] omapdss HDMI: hdmi_runtime_get
[  217.375976] PM: early resume of devices complete after 0.396 msecs
[  217.386474] ------------[ cut here ]------------
[  217.391448] WARNING: at arch/arm/mach-omap2/omap_l3_noc.c:99 l3_interrupt_handler+0x114/0x174()
[  217.400146] Failed to set PHY power mode to 2
[  217.400207] omapdss HDMI: hdmi_runtime_put
[  217.400207] omapdss HDMI: hpd_irq_handler hpd: 1
[  217.414703] L3 standard error: TARGET:DSS  at address 0x6040
[  217.420745] Modules linked in:
[  217.424041] Backtrace:
[  217.426696] [<c0012b58>] (dump_backtrace+0x0/0x114) from [<c04df250>] (dump_stack+0x20/0x24)
[  217.435729]  r6:c0033814 r5:00000009 r4:c06f7e30 r3:c07457cc
[  217.441864] [<c04df230>] (dump_stack+0x0/0x24) from [<c003eccc>] (warn_slowpath_common+0x5c/0x74)
[  217.451385] [<c003ec70>] (warn_slowpath_common+0x0/0x74) from [<c003eda0>] (warn_slowpath_fmt+0x40/0x48)
[  217.461547]  r8:00000000 r7:00000004 r6:00000000 r5:00080001 r4:f003c300
[  217.468597] r3:00000009
[  217.471435] [<c003ed60>] (warn_slowpath_fmt+0x0/0x48) from [<c0033814>] (l3_interrupt_handler+0x114/0x174)
[  217.481781]  r3:c0614d4a r2:c0614c22
[  217.485656] [<c0033700>] (l3_interrupt_handler+0x0/0x174) from [<c008ca50>] (handle_irq_event_percpu+0x98/0x288)
[  217.496551]  r7:0000002a r6:c06fa140 r5:c06f6000 r4:ed0ebd80
[  217.502655] [<c008c9b8>] (handle_irq_event_percpu+0x0/0x288) from [<c008cc8c>] (handle_irq_event+0x4c/0x6c)
[  217.513122] [<c008cc40>] (handle_irq_event+0x0/0x6c) from [<c008fbac>] (handle_fasteoi_irq+0xe0/0x12c)
[  217.523071]  r6:c0718b00 r5:c06fa190 r4:c06fa140 r3:00000000
[  217.529205] [<c008facc>] (handle_fasteoi_irq+0x0/0x12c) from [<c008c360>] (generic_handle_irq+0x30/0x40)
[  217.539337]  r5:00000000 r4:0000002a
[  217.543243] [<c008c330>] (generic_handle_irq+0x0/0x40) from [<c000f5c4>] (handle_IRQ+0x88/0xc8)
[  217.552551]  r4:0000002a r3:00000232
[  217.556427] [<c000f53c>] (handle_IRQ+0x0/0xc8) from [<c000864c>] (gic_handle_irq+0x4c/0x70)
[  217.565368]  r5:fa240100 r4:c06f7f40
[  217.569244] [<c0008600>] (gic_handle_irq+0x0/0x70) from [<c000e180>] (__irq_svc+0x40/0x70)
[  217.578094] Exception stack(0xc06f7f40 to 0xc06f7f88)
[  217.583526] 7f40: c07761a8 aaa2aaaa 4030a43b 00000001 c06f6000 c04ec9c0 ffffffff c06cadec
[  217.592285] 7f60: c0fce1c0 412fc09a 00000000 c06f7f9c c06f7f88 c06f7f88 c000fca4 c000fcb8
[  217.601043] 7f80: 20000113 ffffffff
[  217.604766]  r6:ffffffff r5:20000113 r4:c000fcb8 r3:c000fca4
[  217.610931] [<c000fc18>] (cpu_idle+0x0/0x114) from [<c04ce548>] (rest_init+0x7c/0x94)
[  217.619293]  r5:00000000 r4:00000002
[  217.623199] [<c04ce4cc>] (rest_init+0x0/0x94) from [<c069885c>] (start_kernel+0x2b4/0x304)
[  217.632019]  r4:c0719760 r3:c06d5298
[  217.635894] [<c06985a8>] (start_kernel+0x0/0x304) from [<80008044>] (0x80008044)
[  217.643829] ---[ end trace bfdc309a269b8d17 ]---
[  217.657531] [drm:connector_worker], hotplug event: evt=0, dev=ed3ee800
[  217.664611] omapdss PANEL: tfp410_detect
[  217.669097] omapdss PANEL: tfp410_ddc_read
[  217.673706] omapdss HDMI: hdmi_runtime_get

Signed-off-by: Roger Quadros <rogerq@ti.com>
OMAPDSS: disable l3 errors during suspend/resume

It is possible that DISPC or HDMI interrupt can happen
while DSS core is suspended. In this case runtime_get()
will fail with -EACCESS and we would get L3 errors.

To prevent that we disable the IRQ while suspending and
enable it back on resume.

Signed-off-by: Roger Quadros <rogerq@ti.com>
UBUNTU: version 3.4.0-1487.7

Signed-off-by: Xavier Boudet <x-boudet@ti.com>