CHROMIUM: drm/exynos: Clean up DRM_DEBUG messages
[cascardo/linux.git] / drivers / gpu / drm / exynos / exynos_hdmi.c
index fd1adce..395d4e1 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/delay.h>
-#include <linux/pm_runtime.h>
 #include <linux/clk.h>
 #include <linux/regulator/consumer.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_i2c.h>
 #include <linux/of_gpio.h>
 #include <plat/gpio-cfg.h>
 
 #include <drm/exynos_drm.h>
 
 #include "exynos_drm_drv.h"
-#include "exynos_drm_hdmi.h"
+#include "exynos_drm_display.h"
 
 #include "exynos_hdmi.h"
 
@@ -137,6 +138,7 @@ struct hdmi_context {
        bool                            has_hdmi_audio;
        bool                            is_soc_exynos5;
        bool                            is_hdmi_powered_on;
+       bool                            video_enabled;
 
        struct resource                 *regs_res;
        void __iomem                    *regs;
@@ -153,7 +155,6 @@ struct hdmi_context {
        int cur_conf;
 
        struct hdmi_resources           res;
-       void                            *parent_ctx;
 };
 
 /* HDMI Version 1.3 */
@@ -889,34 +890,30 @@ static bool hdmi_is_connected(void *ctx)
        return true;
 }
 
-static int hdmi_get_edid(void *ctx, struct drm_connector *connector,
-                               u8 *edid, int len)
+static struct edid *hdmi_get_edid(void *ctx, struct drm_connector *connector)
 {
-       struct edid *raw_edid;
        struct hdmi_context *hdata = ctx;
+       struct edid *edid;
 
-       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+       DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", DRM_BASE_ID(connector),
+                       drm_get_connector_name(connector));
 
        if (!hdata->ddc_port)
-               return -ENODEV;
+               return ERR_PTR(-ENODEV);
 
-       raw_edid = drm_get_edid(connector, hdata->ddc_port->adapter);
-       if (raw_edid) {
-       /* TODO : Need to call this in exynos_drm_connector.c, do a drm_get_edid
+       edid = drm_get_edid(connector, hdata->ddc_port->adapter);
+       if (!edid)
+               return ERR_PTR(-ENODEV);
+
+       /*
+        * TODO : Need to call this in exynos_drm_connector.c, do a drm_get_edid
         * to get the edid and then call drm_detect_hdmi_monitor.
         */
-               hdata->has_hdmi_sink = drm_detect_hdmi_monitor(raw_edid);
-               hdata->has_hdmi_audio = drm_detect_monitor_audio(raw_edid);
-               memcpy(edid, raw_edid, min((1 + raw_edid->extensions)
-                                       * EDID_LENGTH, len));
-               DRM_DEBUG_KMS("%s : width[%d] x height[%d]\n",
-                       (hdata->has_hdmi_sink ? "hdmi monitor" : "dvi monitor"),
-                       raw_edid->width_cm, raw_edid->height_cm);
-       } else {
-               return -ENODEV;
-       }
+       hdata->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
+       hdata->has_hdmi_audio = drm_detect_monitor_audio(edid);
+       DRM_DEBUG_KMS("%s monitor\n", hdata->has_hdmi_sink ? "hdmi" : "dvi");
 
-       return 0;
+       return edid;
 }
 
 static int hdmi_v13_check_timing(struct fb_videomode *check_timing)
@@ -989,7 +986,9 @@ void hdmi_reg_infoframe(struct hdmi_context *hdata,
        u32 aspect_ratio;
        u32 mod;
 
-       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+       /* TODO: stringify HDMI_PACKET_TYPE */
+       DRM_DEBUG_KMS("type: %d ver: %d len: %d\n", infoframe->type,
+                       infoframe->ver, infoframe->len);
        mod = hdmi_reg_read(hdata, HDMI_MODE_SEL);
        if (!hdata->has_hdmi_sink) {
                hdmi_reg_writeb(hdata, HDMI_VSI_CON,
@@ -1046,8 +1045,6 @@ static int hdmi_check_timing(void *ctx, void *timing)
        struct hdmi_context *hdata = ctx;
        struct fb_videomode *check_timing = timing;
 
-       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
-
        DRM_DEBUG_KMS("[%d]x[%d] [%d]Hz [%x]\n", check_timing->xres,
                        check_timing->yres, check_timing->refresh,
                        check_timing->vmode);
@@ -1240,6 +1237,33 @@ static void hdmi_conf_reset(struct hdmi_context *hdata)
        hdata->hpd_handle = true;
 }
 
+static void hdmi_enable_video(struct hdmi_context *hdata)
+{
+       if (hdata->is_v13)
+               return;
+
+       hdata->video_enabled = true;
+       hdmi_reg_writemask(hdata, HDMI_CON_0, 0, HDMI_BLUE_SCR_EN);
+}
+
+static void hdmi_disable_video(struct hdmi_context *hdata)
+{
+       if (hdata->is_v13)
+               return;
+
+       /* Set the blue screen color to black */
+       hdmi_reg_writeb(hdata, HDMI_BLUE_SCREEN_R_0, 0);
+       hdmi_reg_writeb(hdata, HDMI_BLUE_SCREEN_R_1, 0);
+       hdmi_reg_writeb(hdata, HDMI_BLUE_SCREEN_G_0, 0);
+       hdmi_reg_writeb(hdata, HDMI_BLUE_SCREEN_G_1, 0);
+       hdmi_reg_writeb(hdata, HDMI_BLUE_SCREEN_B_0, 0);
+       hdmi_reg_writeb(hdata, HDMI_BLUE_SCREEN_B_1, 0);
+
+       /* Enable the "blue screen", which effectively disconnects the mixer */
+       hdata->video_enabled = false;
+       hdmi_reg_writemask(hdata, HDMI_CON_0, ~0, HDMI_BLUE_SCR_EN);
+}
+
 static void hdmi_conf_init(struct hdmi_context *hdata)
 {
        struct hdmi_infoframe infoframe;
@@ -1256,8 +1280,11 @@ static void hdmi_conf_init(struct hdmi_context *hdata)
        /* choose HDMI mode */
        hdmi_reg_writemask(hdata, HDMI_MODE_SEL,
                HDMI_MODE_HDMI_EN, HDMI_MODE_MASK);
-       /* disable bluescreen */
-       hdmi_reg_writemask(hdata, HDMI_CON_0, 0, HDMI_BLUE_SCR_EN);
+
+       if (hdata->video_enabled)
+               hdmi_enable_video(hdata);
+       else
+               hdmi_disable_video(hdata);
 
        if (!hdata->has_hdmi_sink) {
                /* choose DVI mode */
@@ -1601,6 +1628,8 @@ static void hdmiphy_conf_apply(struct hdmi_context *hdata)
        int ret;
        int i;
 
+       DRM_DEBUG_KMS("\n");
+
        if (!hdata->hdmiphy_port) {
                DRM_ERROR("hdmiphy is not attached\n");
                return;
@@ -1646,7 +1675,7 @@ static void hdmiphy_conf_apply(struct hdmi_context *hdata)
 
 static void hdmi_conf_apply(struct hdmi_context *hdata)
 {
-       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+       DRM_DEBUG_KMS("\n");
 
        hdmiphy_conf_reset(hdata);
        hdmiphy_conf_apply(hdata);
@@ -1669,6 +1698,8 @@ static void hdmi_mode_copy(struct drm_display_mode *dst,
 {
        struct drm_mode_object base;
 
+       DRM_DEBUG_KMS("[MODE:%d:%s]\n", DRM_BASE_ID(src), src->name);
+
        /* following information should be preserved,
         * required for releasing the drm_display_mode node,
         * duplicated to recieve adjustment info. */
@@ -1690,7 +1721,10 @@ static void hdmi_mode_fixup(void *ctx, struct drm_connector *connector,
        struct hdmi_context *hdata = ctx;
        int index;
 
-       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+       DRM_DEBUG_KMS("[CONNECTOR:%d:%s] [MODE:%d:%s]\n",
+                       DRM_BASE_ID(connector),
+                       drm_get_connector_name(connector),
+                       DRM_BASE_ID(mode), mode->name);
 
        drm_mode_set_crtcinfo(adjusted_mode, 0);
 
@@ -1736,6 +1770,8 @@ static void hdmi_v14_mode_set(struct hdmi_context *hdata,
        struct hdmi_core_regs *core = &hdata->mode_conf.core;
        struct hdmi_tg_regs *tg = &hdata->mode_conf.tg;
 
+       DRM_DEBUG_KMS("[MODE:%d:%s]\n", DRM_BASE_ID(m), m->name);
+
        hdata->mode_conf.vic = drm_match_cea_mode(m);
 
        hdata->mode_conf.pixel_clock = m->clock * 1000;
@@ -1836,20 +1872,26 @@ static void hdmi_v14_mode_set(struct hdmi_context *hdata,
        hdmi_set_reg(tg->field_bot_hdmi, 2, 0x233); /* Reset value */
        hdmi_set_reg(tg->tg_3d, 1, 0x0);
 
-       /* Workaround 4 implementation for 1440x900 resolution support */
        if (hdata->is_soc_exynos5) {
+               /* Workaround 4 implementation for 1440x900 resolution support */
                if (m->hdisplay == 1440 && m->vdisplay == 900 && m->clock == 106500) {
                        hdmi_set_reg(tg->hact_st, 2, m->htotal - m->hdisplay - 0xe0);
                        hdmi_set_reg(tg->hact_sz, 2, m->hdisplay + 0xe0);
                }
+
+               /* Workaround 3 implementation for 800x600 resolution support */
+               if (m->hdisplay == 800 && m->vdisplay == 600 && m->clock == 40000) {
+                       hdmi_set_reg(tg->hact_st, 2, m->htotal - m->hdisplay - 0x20);
+                       hdmi_set_reg(tg->hact_sz, 2, m->hdisplay + 0x20);
+               }
        }
 }
 
-static void hdmi_mode_set(void *ctx, void *mode)
+static void hdmi_mode_set(void *ctx, struct drm_display_mode *mode)
 {
        struct hdmi_context *hdata = ctx;
 
-       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+       DRM_DEBUG_KMS("[MODE:%d:%s]\n", DRM_BASE_ID(mode), mode->name);
 
        if (hdata->is_v13)
                hdata->cur_conf = hdmi_v13_conf_index(mode);
@@ -1861,7 +1903,8 @@ static void hdmi_commit(void *ctx)
 {
        struct hdmi_context *hdata = ctx;
 
-       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+       DRM_DEBUG_KMS("is_hdmi_powered_on: %u\n", hdata->is_hdmi_powered_on);
+
        if (!hdata->is_hdmi_powered_on)
                return;
 
@@ -1869,24 +1912,161 @@ static void hdmi_commit(void *ctx)
        hdata->enabled = true;
 }
 
-static int hdmi_power_on(void *ctx, int mode)
+static int hdmiphy_update_bits(struct i2c_client *client, u8 *reg_cache,
+                              u8 reg, u8 mask, u8 val)
+{
+       int ret;
+       u8 buffer[2];
+
+       buffer[0] = reg;
+       buffer[1] = (reg_cache[reg] & ~mask) | (val & mask);
+       reg_cache[reg] = buffer[1];
+
+       ret = i2c_master_send(client, buffer, 2);
+       if (ret != 2)
+               return -EIO;
+
+       return 0;
+}
+
+static int hdmiphy_s_power(struct i2c_client *client, bool on)
+{
+       u8 reg_cache[32] = { 0 };
+       u8 buffer[2];
+       int ret;
+
+       DRM_DEBUG_KMS("%s\n", on ? "on" : "off");
+
+       /* Cache all 32 registers to make the code below faster */
+       buffer[0] = 0x0;
+       ret = i2c_master_send(client, buffer, 1);
+       if (ret != 1) {
+               ret = -EIO;
+               goto exit;
+       }
+       ret = i2c_master_recv(client, reg_cache, 32);
+       if (ret != 32) {
+               ret = -EIO;
+               goto exit;
+       }
+
+       /* Go to/from configuration from/to operation mode */
+       ret = hdmiphy_update_bits(client, reg_cache, 0x1f, 0xff,
+                                 on ? 0x80 : 0x00);
+       if (ret)
+               goto exit;
+
+       /*
+        * Turn off undocumented "oscpad" if !on; it turns on again in
+        * hdmiphy_conf_apply()
+        */
+       if (!on)
+               ret = hdmiphy_update_bits(client, reg_cache, 0x0b, 0xc0, 0x00);
+               if (ret)
+                       goto exit;
+
+       /* Disable powerdown if on; enable if !on */
+       ret = hdmiphy_update_bits(client, reg_cache, 0x1d, 0x80,
+                                 on ? 0 : ~0);
+       if (ret)
+               goto exit;
+       ret = hdmiphy_update_bits(client, reg_cache, 0x1d, 0x77,
+                                 on ? 0 : ~0);
+       if (ret)
+               goto exit;
+
+       /*
+        * Turn off bit 3 of reg 4 if !on; it turns on again in
+        * hdmiphy_conf_apply().  It's unclear what this bit does.
+        */
+       if (!on)
+               ret = hdmiphy_update_bits(client, reg_cache, 0x04, BIT(3), 0);
+               if (ret)
+                       goto exit;
+
+exit:
+       /* Don't expect any errors so just do a single warn */
+       WARN_ON(ret);
+
+       return ret;
+}
+
+static void hdmi_resource_poweron(struct hdmi_context *hdata)
+{
+       struct hdmi_resources *res = &hdata->res;
+
+       hdata->is_hdmi_powered_on = true;
+       hdmi_cfg_hpd(hdata, false);
+
+       /* irq change by TV power status */
+       if (hdata->curr_irq == hdata->internal_irq)
+               return;
+
+       disable_irq(hdata->curr_irq);
+
+       hdata->curr_irq = hdata->internal_irq;
+
+       enable_irq(hdata->curr_irq);
+
+       /* turn HDMI power on */
+       regulator_bulk_enable(res->regul_count, res->regul_bulk);
+
+       /* power-on hdmi clocks */
+       clk_enable(res->hdmiphy);
+
+       hdmiphy_s_power(hdata->hdmiphy_port, 1);
+       hdmiphy_conf_reset(hdata);
+       hdmi_conf_reset(hdata);
+       hdmi_conf_init(hdata);
+       if (!hdata->is_soc_exynos5)
+               hdmi_audio_init(hdata);
+       hdmi_commit(hdata);
+}
+
+static void hdmi_resource_poweroff(struct hdmi_context *hdata)
+{
+       struct hdmi_resources *res = &hdata->res;
+
+       hdmi_cfg_hpd(hdata, true);
+
+       if (hdata->curr_irq == hdata->external_irq)
+               return;
+
+       disable_irq(hdata->curr_irq);
+       hdata->curr_irq = hdata->external_irq;
+
+       enable_irq(hdata->curr_irq);
+       hdata->is_hdmi_powered_on = false;
+
+       hdmiphy_s_power(hdata->hdmiphy_port, 0);
+       hdmiphy_conf_reset(hdata);
+
+       /* power-off hdmi clocks */
+       clk_disable(res->hdmiphy);
+
+       /* turn HDMI power off */
+       regulator_bulk_disable(res->regul_count, res->regul_bulk);
+}
+
+static int hdmi_dpms(void *ctx, int mode)
 {
        struct hdmi_context *hdata = ctx;
 
+       DRM_DEBUG_KMS("[DPMS:%s]\n", drm_get_dpms_name(mode));
+
        switch (mode) {
        case DRM_MODE_DPMS_ON:
-               if (!hdata->is_hdmi_powered_on) {
-                       pm_runtime_get_sync(hdata->dev);
-                       hdmi_commit(ctx);
-               }
+               if (!hdata->is_hdmi_powered_on)
+                       hdmi_resource_poweron(hdata);
+               hdmi_enable_video(hdata);
                break;
        case DRM_MODE_DPMS_STANDBY:
-               break;
-       case DRM_MODE_DPMS_SUSPEND:
+               hdmi_disable_video(hdata);
                break;
        case DRM_MODE_DPMS_OFF:
+       case DRM_MODE_DPMS_SUSPEND:
                if (hdata->is_hdmi_powered_on)
-                       pm_runtime_put_sync(hdata->dev);
+                       hdmi_resource_poweroff(hdata);
                break;
        default:
                DRM_DEBUG_KMS("unknown dpms mode: %d\n", mode);
@@ -1896,12 +2076,24 @@ static int hdmi_power_on(void *ctx, int mode)
        return 0;
 }
 
-static struct exynos_hdmi_ops hdmi_ops = {
+static int hdmi_subdrv_probe(void *ctx, struct drm_device *drm_dev)
+{
+       struct hdmi_context *hdata = ctx;
+
+       DRM_DEBUG_KMS("[DEV:%s]\n", drm_dev->devname);
+
+       hdata->drm_dev = drm_dev;
+
+       return 0;
+}
+
+static struct exynos_panel_ops hdmi_ops = {
        /* display */
+       .subdrv_probe   = hdmi_subdrv_probe,
        .is_connected   = hdmi_is_connected,
        .get_edid       = hdmi_get_edid,
        .check_timing   = hdmi_check_timing,
-       .power_on       = hdmi_power_on,
+       .dpms           = hdmi_dpms,
 
        /* manager */
        .mode_fixup     = hdmi_mode_fixup,
@@ -1916,16 +2108,13 @@ static void hdmi_hotplug_func(struct work_struct *work)
 {
        struct hdmi_context *hdata =
                container_of(work, struct hdmi_context, hotplug_work);
-       struct exynos_drm_hdmi_context *ctx =
-               (struct exynos_drm_hdmi_context *)hdata->parent_ctx;
 
-       drm_helper_hpd_irq_event(ctx->drm_dev);
+       drm_helper_hpd_irq_event(hdata->drm_dev);
 }
 
 static irqreturn_t hdmi_irq_handler(int irq, void *arg)
 {
-       struct exynos_drm_hdmi_context *ctx = arg;
-       struct hdmi_context *hdata = ctx->ctx;
+       struct hdmi_context *hdata = arg;
        u32 intc_flag;
        if (hdata->is_hdmi_powered_on) {
                intc_flag = hdmi_reg_read(hdata, HDMI_INTC_FLAG);
@@ -1944,7 +2133,7 @@ static irqreturn_t hdmi_irq_handler(int irq, void *arg)
                }
        }
 
-       if (ctx->drm_dev && hdata->hpd_handle)
+       if (hdata->drm_dev && hdata->hpd_handle)
                queue_work(hdata->wq, &hdata->hotplug_work);
 
        return IRQ_HANDLED;
@@ -2050,228 +2239,16 @@ static int hdmi_resources_cleanup(struct hdmi_context *hdata)
        return 0;
 }
 
-static int hdmiphy_update_bits(struct i2c_client *client, u8 *reg_cache,
-                              u8 reg, u8 mask, u8 val)
-{
-       int ret;
-       u8 buffer[2];
-
-       buffer[0] = reg;
-       buffer[1] = (reg_cache[reg] & ~mask) | (val & mask);
-       reg_cache[reg] = buffer[1];
-
-       ret = i2c_master_send(client, buffer, 2);
-       if (ret != 2)
-               return -EIO;
-
-       return 0;
-}
-
-static int hdmiphy_s_power(struct i2c_client *client, bool on)
-{
-       u8 reg_cache[32] = { 0 };
-       u8 buffer[2];
-       int ret;
-
-       DRM_DEBUG_KMS("%s: hdmiphy is %s\n", __func__, on ? "on" : "off");
-
-       /* Cache all 32 registers to make the code below faster */
-       buffer[0] = 0x0;
-       ret = i2c_master_send(client, buffer, 1);
-       if (ret != 1) {
-               ret = -EIO;
-               goto exit;
-       }
-       ret = i2c_master_recv(client, reg_cache, 32);
-       if (ret != 32) {
-               ret = -EIO;
-               goto exit;
-       }
-
-       /* Go to/from configuration from/to operation mode */
-       ret = hdmiphy_update_bits(client, reg_cache, 0x1f, 0xff,
-                                 on ? 0x80 : 0x00);
-       if (ret)
-               goto exit;
-
-       /*
-        * Turn off undocumented "oscpad" if !on; it turns on again in
-        * hdmiphy_conf_apply()
-        */
-       if (!on)
-               ret = hdmiphy_update_bits(client, reg_cache, 0x0b, 0xc0, 0x00);
-               if (ret)
-                       goto exit;
-
-       /* Disable powerdown if on; enable if !on */
-       ret = hdmiphy_update_bits(client, reg_cache, 0x1d, 0x80,
-                                 on ? 0 : ~0);
-       if (ret)
-               goto exit;
-       ret = hdmiphy_update_bits(client, reg_cache, 0x1d, 0x77,
-                                 on ? 0 : ~0);
-       if (ret)
-               goto exit;
-
-       /*
-        * Turn off bit 3 of reg 4 if !on; it turns on again in
-        * hdmiphy_conf_apply().  It's unclear what this bit does.
-        */
-       if (!on)
-               ret = hdmiphy_update_bits(client, reg_cache, 0x04, BIT(3), 0);
-               if (ret)
-                       goto exit;
-
-exit:
-       /* Don't expect any errors so just do a single warn */
-       WARN_ON(ret);
-
-       return ret;
-}
-
-static void hdmi_resource_poweron(struct hdmi_context *hdata)
-{
-       struct hdmi_resources *res = &hdata->res;
-
-       hdata->is_hdmi_powered_on = true;
-       hdmi_cfg_hpd(hdata, false);
-
-       /* irq change by TV power status */
-       if (hdata->curr_irq == hdata->internal_irq)
-               return;
-
-       disable_irq(hdata->curr_irq);
-
-       hdata->curr_irq = hdata->internal_irq;
-
-       enable_irq(hdata->curr_irq);
-
-       /* turn HDMI power on */
-       regulator_bulk_enable(res->regul_count, res->regul_bulk);
-
-       /* power-on hdmi clocks */
-       clk_enable(res->hdmiphy);
-
-       hdmiphy_s_power(hdata->hdmiphy_port, 1);
-       hdmiphy_conf_reset(hdata);
-       hdmi_conf_reset(hdata);
-       hdmi_conf_init(hdata);
-       if (!hdata->is_soc_exynos5)
-               hdmi_audio_init(hdata);
-}
-
-static void hdmi_resource_poweroff(struct hdmi_context *hdata)
-{
-       struct hdmi_resources *res = &hdata->res;
-
-       hdmi_cfg_hpd(hdata, true);
-
-       if (hdata->curr_irq == hdata->external_irq)
-               return;
-
-       disable_irq(hdata->curr_irq);
-       hdata->curr_irq = hdata->external_irq;
-
-       enable_irq(hdata->curr_irq);
-       hdata->is_hdmi_powered_on = false;
-
-       hdmiphy_s_power(hdata->hdmiphy_port, 0);
-       hdmiphy_conf_reset(hdata);
-
-       /* power-off hdmi clocks */
-       clk_disable(res->hdmiphy);
-
-       /* turn HDMI power off */
-       regulator_bulk_disable(res->regul_count, res->regul_bulk);
-}
-
-#ifdef CONFIG_PM_SLEEP
-static int hdmi_suspend(struct device *dev)
-{
-       struct exynos_drm_hdmi_context *ctx = get_hdmi_context(dev);
-       struct hdmi_context *hdata = ctx->ctx;
-
-       DRM_DEBUG_KMS("[hdmi] sleep suspend - start\n");
-       if (pm_runtime_suspended(dev)) {
-               DRM_DEBUG_KMS("[hdmi] sleep suspend - already suspended\n");
-               return 0;
-       }
-
-       hdmi_resource_poweroff(hdata);
-       DRM_DEBUG_KMS("[hdmi] sleep suspend - end\n");
-
-       return 0;
-}
-static int hdmi_resume(struct device *dev)
-{
-       struct exynos_drm_hdmi_context *ctx = get_hdmi_context(dev);
-       struct hdmi_context *hdata = ctx->ctx;
-
-       DRM_DEBUG_KMS("[hdmi] sleep resume - start\n");
-
-       if (!pm_runtime_suspended(dev)) {
-               hdmi_resource_poweron(hdata);
-               hdmi_commit(hdata);
-               DRM_DEBUG_KMS("[hdmi] sleep resuming\n");
-       }
-       DRM_DEBUG_KMS("[hdmi] sleep resume - end\n");
-       return 0;
-}
-#endif
-#ifdef CONFIG_PM_RUNTIME
-static int hdmi_runtime_suspend(struct device *dev)
-{
-       struct exynos_drm_hdmi_context *ctx = get_hdmi_context(dev);
-       struct hdmi_context *hdata = ctx->ctx;
-
-       DRM_DEBUG_KMS("[hdmi] runtime suspend - start\n");
-       hdmi_resource_poweroff(hdata);
-       DRM_DEBUG_KMS("[hdmi] runtime suspend - end\n");
-
-       return 0;
-}
-
-static int hdmi_runtime_resume(struct device *dev)
-{
-       struct exynos_drm_hdmi_context *ctx = get_hdmi_context(dev);
-       struct hdmi_context *hdata = ctx->ctx;
-
-       DRM_DEBUG_KMS("[hdmi] runtime resume - start\n");
-
-       hdmi_resource_poweron(hdata);
-
-       DRM_DEBUG_KMS("[hdmi] runtime resume - end\n");
-       return 0;
-}
-#endif
-static const struct dev_pm_ops hdmi_pm_ops = {
-       SET_SYSTEM_SLEEP_PM_OPS(hdmi_suspend, hdmi_resume)
-       SET_RUNTIME_PM_OPS(hdmi_runtime_suspend, hdmi_runtime_resume, NULL)
-};
-
-static struct i2c_client *hdmi_ddc, *hdmi_hdmiphy;
-
-void hdmi_attach_ddc_client(struct i2c_client *ddc)
-{
-       if (ddc)
-               hdmi_ddc = ddc;
-}
-
-void hdmi_attach_hdmiphy_client(struct i2c_client *hdmiphy)
-{
-       if (hdmiphy)
-               hdmi_hdmiphy = hdmiphy;
-}
-
 struct platform_device *hdmi_audio_device;
 
 int hdmi_register_audio_device(struct platform_device *pdev)
 {
-       struct exynos_drm_hdmi_context *ctx = platform_get_drvdata(pdev);
-       struct hdmi_context *hdata = ctx->ctx;
+       struct hdmi_context *hdata = platform_get_drvdata(pdev);
        struct platform_device *audio_dev;
        int ret;
 
+       DRM_DEBUG_KMS("[PDEV:%s]\n", pdev->name);
+
        audio_dev = platform_device_alloc("exynos-hdmi-audio", -1);
        if (!audio_dev) {
                DRM_ERROR("hdmi audio device allocation failed.\n");
@@ -2307,20 +2284,21 @@ err:
 
 void hdmi_unregister_audio_device(void)
 {
+       DRM_DEBUG_KMS("\n");
        platform_device_unregister(hdmi_audio_device);
 }
 
 static int __devinit hdmi_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct exynos_drm_hdmi_context *drm_hdmi_ctx;
        struct hdmi_context *hdata;
        struct exynos_drm_hdmi_pdata *pdata;
        struct resource *res;
+       struct device_node *ddc_node, *phy_node;
        int ret;
        enum of_gpio_flags flags;
 
-       DRM_DEBUG_KMS("[%d]\n", __LINE__);
+       DRM_DEBUG_KMS("[PDEV:%s]\n", pdev->name);
 
        pdata = pdev->dev.platform_data;
        if (!pdata) {
@@ -2328,23 +2306,13 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       drm_hdmi_ctx = kzalloc(sizeof(*drm_hdmi_ctx), GFP_KERNEL);
-       if (!drm_hdmi_ctx) {
-               DRM_ERROR("failed to allocate common hdmi context.\n");
-               return -ENOMEM;
-       }
-
        hdata = kzalloc(sizeof(struct hdmi_context), GFP_KERNEL);
        if (!hdata) {
                DRM_ERROR("out of memory\n");
-               kfree(drm_hdmi_ctx);
                return -ENOMEM;
        }
 
-       drm_hdmi_ctx->ctx = (void *)hdata;
-       hdata->parent_ctx = (void *)drm_hdmi_ctx;
-
-       platform_set_drvdata(pdev, drm_hdmi_ctx);
+       platform_set_drvdata(pdev, hdata);
 
        hdata->is_v13 = pdata->is_v13;
        hdata->default_win = pdata->default_win;
@@ -2383,22 +2351,32 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
        }
 
        /* DDC i2c driver */
-       if (i2c_add_driver(&ddc_driver)) {
-               DRM_ERROR("failed to register ddc i2c driver\n");
-               ret = -ENOENT;
+       ddc_node = of_find_node_by_name(NULL, "exynos_ddc");
+       if (!ddc_node) {
+               DRM_ERROR("Failed to find ddc node in device tree\n");
+               ret = -ENODEV;
+               goto err_iomap;
+       }
+       hdata->ddc_port = of_find_i2c_device_by_node(ddc_node);
+       if (!hdata->ddc_port) {
+               DRM_ERROR("Failed to get ddc i2c client by node\n");
+               ret = -ENODEV;
                goto err_iomap;
        }
-
-       hdata->ddc_port = hdmi_ddc;
 
        /* hdmiphy i2c driver */
-       if (i2c_add_driver(&hdmiphy_driver)) {
-               DRM_ERROR("failed to register hdmiphy i2c driver\n");
-               ret = -ENOENT;
+       phy_node = of_find_node_by_name(NULL, "exynos_hdmiphy");
+       if (!phy_node) {
+               DRM_ERROR("Failed to find hdmiphy node in device tree\n");
+               ret = -ENODEV;
+               goto err_ddc;
+       }
+       hdata->hdmiphy_port = of_find_i2c_device_by_node(phy_node);
+       if (!hdata->hdmiphy_port) {
+               DRM_ERROR("Failed to get hdmi phy i2c client from node\n");
+               ret = -ENODEV;
                goto err_ddc;
        }
-
-       hdata->hdmiphy_port = hdmi_hdmiphy;
 
        res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        if (res == NULL) {
@@ -2431,7 +2409,7 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
        INIT_WORK(&hdata->hotplug_work, hdmi_hotplug_func);
 
        ret = request_irq(hdata->internal_irq, hdmi_irq_handler,
-                       IRQF_SHARED, "int_hdmi", hdata->parent_ctx);
+                       IRQF_SHARED, "int_hdmi", hdata);
        if (ret) {
                DRM_ERROR("request int interrupt failed.\n");
                goto err_workqueue;
@@ -2440,7 +2418,7 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
 
        ret = request_irq(hdata->external_irq, hdmi_irq_handler,
                IRQ_TYPE_EDGE_BOTH | IRQF_SHARED, "ext_hdmi",
-               hdata->parent_ctx);
+               hdata);
        if (ret) {
                DRM_ERROR("request ext interrupt failed.\n");
                goto err_int_irq;
@@ -2456,20 +2434,16 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
                }
        }
 
-       /* Attach HDMI Driver to common hdmi. */
-       exynos_hdmi_drv_attach(drm_hdmi_ctx);
-
-       /* register specific callbacks to common hdmi. */
-       exynos_hdmi_ops_register(&hdmi_ops);
        hdmi_resource_poweron(hdata);
-       pm_runtime_enable(dev);
 
        if (!hdmi_is_connected(hdata)) {
                hdmi_resource_poweroff(hdata);
                DRM_DEBUG_KMS("gpio state is low. powering off!\n");
-       } else {
-               pm_runtime_get_sync(dev);
        }
+
+       exynos_display_attach_panel(EXYNOS_DRM_DISPLAY_TYPE_MIXER, &hdmi_ops,
+                       hdata);
+
        return 0;
 
 err_ext_irq:
@@ -2479,9 +2453,9 @@ err_int_irq:
  err_workqueue:
        destroy_workqueue(hdata->wq);
 err_hdmiphy:
-       i2c_del_driver(&hdmiphy_driver);
+       put_device(&hdata->hdmiphy_port->dev);
 err_ddc:
-       i2c_del_driver(&ddc_driver);
+       put_device(&hdata->ddc_port->dev);
 err_iomap:
        iounmap(hdata->regs);
 err_req_region:
@@ -2491,17 +2465,15 @@ err_resource:
        hdmi_resources_cleanup(hdata);
 err_data:
        kfree(hdata);
-       kfree(drm_hdmi_ctx);
        return ret;
 }
 
 static int __devexit hdmi_remove(struct platform_device *pdev)
 {
-       struct exynos_drm_hdmi_context *ctx = platform_get_drvdata(pdev);
-       struct hdmi_context *hdata = ctx->ctx;
+       struct hdmi_context *hdata = platform_get_drvdata(pdev);
        struct hdmi_resources *res = &hdata->res;
 
-       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+       DRM_DEBUG_KMS("[PDEV:%s]\n", pdev->name);
 
        hdmi_resource_poweroff(hdata);
 
@@ -2523,10 +2495,8 @@ static int __devexit hdmi_remove(struct platform_device *pdev)
        release_mem_region(hdata->regs_res->start,
                        resource_size(hdata->regs_res));
 
-       /* hdmiphy i2c driver */
-       i2c_del_driver(&hdmiphy_driver);
-       /* DDC i2c driver */
-       i2c_del_driver(&ddc_driver);
+       put_device(&hdata->hdmiphy_port->dev);
+       put_device(&hdata->ddc_port->dev);
 
        kfree(hdata);
 
@@ -2543,6 +2513,5 @@ struct platform_driver hdmi_driver = {
                .name   = "exynos4-hdmi",
 #endif
                .owner  = THIS_MODULE,
-               .pm = &hdmi_pm_ops,
        },
 };