From patchwork Thu Sep 8 13:36:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Mythri P" X-Patchwork-Id: 1129972 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p88DioR9003799 for ; Thu, 8 Sep 2011 13:44:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932938Ab1IHNom (ORCPT ); Thu, 8 Sep 2011 09:44:42 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:34525 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932908Ab1IHNog (ORCPT ); Thu, 8 Sep 2011 09:44:36 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id p88DiXHH016100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 8 Sep 2011 08:44:35 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id p88DiWuf003415 for ; Thu, 8 Sep 2011 19:14:32 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 8.3.106.1; Thu, 8 Sep 2011 19:14:33 +0530 Received: from localhost.localdomain (graphicspc.apr.dhcp.ti.com [172.24.136.217]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p88DiTJC027781; Thu, 8 Sep 2011 19:14:32 +0530 (IST) From: To: , CC: Mythri P K Subject: [PATCH 09/10] OMAP4: DSS2: HDMI: Function pointer approach to call Date: Thu, 8 Sep 2011 19:06:26 +0530 Message-ID: <1315488987-4546-10-git-send-email-mythripk@ti.com> X-Mailer: git-send-email 1.5.6.3 In-Reply-To: <1315488987-4546-9-git-send-email-mythripk@ti.com> References: <1315488987-4546-1-git-send-email-mythripk@ti.com> <1315488987-4546-2-git-send-email-mythripk@ti.com> <1315488987-4546-3-git-send-email-mythripk@ti.com> <1315488987-4546-4-git-send-email-mythripk@ti.com> <1315488987-4546-5-git-send-email-mythripk@ti.com> <1315488987-4546-6-git-send-email-mythripk@ti.com> <1315488987-4546-7-git-send-email-mythripk@ti.com> <1315488987-4546-8-git-send-email-mythripk@ti.com> <1315488987-4546-9-git-send-email-mythripk@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 08 Sep 2011 13:44:50 +0000 (UTC) From: Mythri P K HDMI IP fundamentally has replaceable core PHY and PLL blocks. These blocks might vary across OMAP's but the end functionality such as to enable or disable PLL, PHY, function to read EDID would remain the same. Thus to make the current hdmi DSS driver compatible with different OMAP's having different IP blocks( A combination of different core, PHY, PLL blocks), function pointer approach is introduced. With function pointer, relevant IP dependent functions are mapped to the generic functions used by DSS during the initialization based on the OMAP compiled. Thus making hdmi DSS driver IP agnostic. Signed-off-by: Mythri P K --- drivers/video/omap2/dss/dss_features.c | 20 ++++++++++++++++++++ drivers/video/omap2/dss/dss_features.h | 7 +++++++ drivers/video/omap2/dss/hdmi.c | 19 ++++++++++--------- drivers/video/omap2/dss/ti_hdmi.h | 21 +++++++++++++++++++++ 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/drivers/video/omap2/dss/dss_features.c b/drivers/video/omap2/dss/dss_features.c index b63c5f8..8670612 100644 --- a/drivers/video/omap2/dss/dss_features.c +++ b/drivers/video/omap2/dss/dss_features.c @@ -429,6 +429,26 @@ static const struct omap_dss_features omap4_dss_features = { .burst_size_unit = 16, }; +#if defined(CONFIG_OMAP4_DSS_HDMI) +/* HDMI OMAP4 Functions*/ +static const struct ti_hdmi_ip_ops omap4_hdmi_functions = { + + .video_configure = ti_hdmi_4xxx_basic_configure, + .phy_enable = ti_hdmi_4xxx_phy_enable, + .phy_disable = ti_hdmi_4xxx_phy_disable, + .read_edid = ti_hdmi_4xxx_read_edid, + .pll_enable = ti_hdmi_4xxx_pll_enable, + .pll_disable = ti_hdmi_4xxx_pll_disable, + .video_enable = ti_hdmi_4xxx_wp_video_start, +}; + +void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data) +{ + if (cpu_is_omap44xx()) + ip_data->ops = &omap4_hdmi_functions; +} +#endif + /* Functions returning values related to a DSS feature */ int dss_feat_get_num_mgrs(void) { diff --git a/drivers/video/omap2/dss/dss_features.h b/drivers/video/omap2/dss/dss_features.h index 4271e96..e89ae5f 100644 --- a/drivers/video/omap2/dss/dss_features.h +++ b/drivers/video/omap2/dss/dss_features.h @@ -20,6 +20,10 @@ #ifndef __OMAP2_DSS_FEATURES_H #define __OMAP2_DSS_FEATURES_H +#if defined(CONFIG_OMAP4_DSS_HDMI) +#include "ti_hdmi.h" +#endif + #define MAX_DSS_MANAGERS 3 #define MAX_DSS_OVERLAYS 3 #define MAX_DSS_LCD_MANAGERS 2 @@ -99,4 +103,7 @@ u32 dss_feat_get_burst_size_unit(void); /* in bytes */ bool dss_has_feature(enum dss_feat_id id); void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end); void dss_features_init(void); +#if defined(CONFIG_OMAP4_DSS_HDMI) +void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data); +#endif #endif diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c index 5afc51b..8cef940 100644 --- a/drivers/video/omap2/dss/hdmi.c +++ b/drivers/video/omap2/dss/hdmi.c @@ -186,6 +186,7 @@ int hdmi_init_display(struct omap_dss_device *dssdev) { DSSDBG("init_display\n"); + dss_init_hdmi_ip_ops(&hdmi.ip_data); return 0; } @@ -366,7 +367,7 @@ static void hdmi_read_edid(struct omap_video_timings *dp) memset(hdmi.edid, 0, HDMI_EDID_MAX_LENGTH); if (!hdmi.edid_set) - ret = ti_hdmi_4xxx_read_edid(&hdmi.ip_data, hdmi.edid, + ret = hdmi.ip_data.ops->read_edid(&hdmi.ip_data, hdmi.edid, HDMI_EDID_MAX_LENGTH); if (!ret) { if (!memcmp(hdmi.edid, edid_header, sizeof(edid_header))) { @@ -480,16 +481,16 @@ static int hdmi_power_on(struct omap_dss_device *dssdev) hdmi_compute_pll(dssdev, phy, &hdmi.ip_data.pll_data); - ti_hdmi_4xxx_wp_video_start(&hdmi.ip_data, 0); + hdmi.ip_data.ops->video_enable(&hdmi.ip_data, 0); /* config the PLL and PHY hdmi_set_pll_pwrfirst */ - r = ti_hdmi_4xxx_pll_enable(&hdmi.ip_data); + r = hdmi.ip_data.ops->pll_enable(&hdmi.ip_data); if (r) { DSSDBG("Failed to lock PLL\n"); goto err; } - r = ti_hdmi_4xxx_phy_enable(&hdmi.ip_data); + r = hdmi.ip_data.ops->phy_enable(&hdmi.ip_data); if (r) { DSSDBG("Failed to start PHY\n"); goto err; @@ -497,7 +498,7 @@ static int hdmi_power_on(struct omap_dss_device *dssdev) hdmi.ip_data.cfg.cm.mode = hdmi.mode; hdmi.ip_data.cfg.cm.code = hdmi.code; - ti_hdmi_4xxx_basic_configure(&hdmi.ip_data); + hdmi.ip_data.ops->video_configure(&hdmi.ip_data); /* Make selection of HDMI in DSS */ dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK); @@ -519,7 +520,7 @@ static int hdmi_power_on(struct omap_dss_device *dssdev) dispc_mgr_enable(OMAP_DSS_CHANNEL_DIGIT, 1); - ti_hdmi_4xxx_wp_video_start(&hdmi.ip_data, 1); + hdmi.ip_data.ops->video_enable(&hdmi.ip_data, 1); return 0; err: @@ -531,9 +532,9 @@ static void hdmi_power_off(struct omap_dss_device *dssdev) { dispc_mgr_enable(OMAP_DSS_CHANNEL_DIGIT, 0); - ti_hdmi_4xxx_wp_video_start(&hdmi.ip_data, 0); - ti_hdmi_4xxx_phy_disable(&hdmi.ip_data); - ti_hdmi_4xxx_pll_disable(&hdmi.ip_data); + hdmi.ip_data.ops->video_enable(&hdmi.ip_data, 0); + hdmi.ip_data.ops->phy_disable(&hdmi.ip_data); + hdmi.ip_data.ops->pll_disable(&hdmi.ip_data); hdmi_runtime_put(); hdmi.edid_set = 0; diff --git a/drivers/video/omap2/dss/ti_hdmi.h b/drivers/video/omap2/dss/ti_hdmi.h index 823fbe6..acf1022 100644 --- a/drivers/video/omap2/dss/ti_hdmi.h +++ b/drivers/video/omap2/dss/ti_hdmi.h @@ -21,6 +21,8 @@ #ifndef _TI_HDMI_H #define _TI_HDMI_H +struct hdmi_ip_data; + enum hdmi_pll_pwr { HDMI_PLLPWRCMD_ALLOFF = 0, HDMI_PLLPWRCMD_PLLONLY = 1, @@ -82,12 +84,31 @@ struct hdmi_pll_info { enum hdmi_clk_refsel refsel; }; +struct ti_hdmi_ip_ops { + + void (*video_configure)(struct hdmi_ip_data *ip_data); + + int (*phy_enable)(struct hdmi_ip_data *ip_data); + + void (*phy_disable)(struct hdmi_ip_data *ip_data); + + int (*read_edid)(struct hdmi_ip_data *ip_data, + u8 *pedid, u16 max_length); + + int (*pll_enable)(struct hdmi_ip_data *ip_data); + + void (*pll_disable)(struct hdmi_ip_data *ip_data); + + void (*video_enable)(struct hdmi_ip_data *ip_data, bool start); +}; + struct hdmi_ip_data { void __iomem *base_wp; /* HDMI wrapper */ unsigned long core_sys_offset; unsigned long core_av_offset; unsigned long pll_offset; unsigned long phy_offset; + const struct ti_hdmi_ip_ops *ops; struct hdmi_config cfg; struct hdmi_pll_info pll_data; };