From patchwork Thu Oct 17 11:26:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: archit taneja X-Patchwork-Id: 3060381 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 49DB19F243 for ; Thu, 17 Oct 2013 11:28:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 895F120394 for ; Thu, 17 Oct 2013 11:28:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC7282039F for ; Thu, 17 Oct 2013 11:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753958Ab3JQL1q (ORCPT ); Thu, 17 Oct 2013 07:27:46 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:39510 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753222Ab3JQL1p (ORCPT ); Thu, 17 Oct 2013 07:27:45 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r9HBRjmN023842; Thu, 17 Oct 2013 06:27:45 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r9HBRjGr017029; Thu, 17 Oct 2013 06:27:45 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Thu, 17 Oct 2013 06:27:45 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id r9HBRjpB026190; Thu, 17 Oct 2013 06:27:45 -0500 Received: from localhost (a0393947pc.apr.dhcp.ti.com [172.24.145.166]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r9HBRht03997; Thu, 17 Oct 2013 06:27:44 -0500 (CDT) From: Archit Taneja To: CC: , , Archit Taneja Subject: [PATCH 4/6] omapdss: hdmi pll: Incorporate changes for OMAP5/DRA7x Date: Thu, 17 Oct 2013 16:56:40 +0530 Message-ID: <1382009202-18984-5-git-send-email-archit@ti.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1382009202-18984-1-git-send-email-archit@ti.com> References: <1382009202-18984-1-git-send-email-archit@ti.com> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a features struct to differentiate between the HDMI PLLs on OMAP4 and OMAP5/DRA7x. The OMAP5/DRA7x PLL are more sensitive compared to the PLL on OMAP4 when it comes to locking. We need to ensure that the DCO freq calculated isn't too low for lower pixel clocks. If not followed, the PLL doesn't lock for lower frequencies. Modify the PLL computation slightly to ensure the HDMI PLL locks for lower frequencies. This will be replaced by a more complex computation which makes sure all the PLL constraints are met. Signed-off-by: Archit Taneja --- drivers/video/omap2/dss/hdmi_pll.c | 74 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/drivers/video/omap2/dss/hdmi_pll.c b/drivers/video/omap2/dss/hdmi_pll.c index d3e6e78..e1c55c4 100644 --- a/drivers/video/omap2/dss/hdmi_pll.c +++ b/drivers/video/omap2/dss/hdmi_pll.c @@ -21,6 +21,13 @@ #define HDMI_DEFAULT_REGN 16 #define HDMI_DEFAULT_REGM2 1 +struct hdmi_pll_features { + bool sys_reset; + bool bound_dcofreq; +}; + +static const struct hdmi_pll_features *pll_feat; + void hdmi_pll_dump(struct hdmi_pll_data *pll, struct seq_file *s) { #define DUMPPLL(r) seq_printf(s, "%-35s %08x\n", #r,\ @@ -55,7 +62,17 @@ void hdmi_pll_compute(struct hdmi_pll_data *pll, unsigned long clkin, int phy) refclk = clkin / pi->regn; - pi->regm2 = HDMI_DEFAULT_REGM2; + /* + * HACK: the HDMI PLL on omap5/dra7x doesn't lock if the required + * DCOFREQ is lesser than the minimum value of the DCO's lower frequency + * range. For now, we just make sure that low pixel clock rates also + * generate a high enough DCOFREQ by setting the M2 post divider to a + * higher value + */ + if (pll_feat->bound_dcofreq && phy <= 65000) + pi->regm2 = 3; + else + pi->regm2 = HDMI_DEFAULT_REGM2; /* * multiplier is pixel_clk/ref_clk @@ -151,8 +168,12 @@ static int hdmi_pll_config(struct hdmi_pll_data *pll) static int hdmi_pll_reset(struct hdmi_pll_data *pll) { - /* SYSRESET controlled by power FSM */ - REG_FLD_MOD(pll->base, PLLCTRL_PLL_CONTROL, 0x0, 3, 3); + /* + * SYSRESET controlled by power FSM. + * SYSRESETN needs to be set for omap5/dra7x, but cleared for omap4 + * HDMI PLL + */ + REG_FLD_MOD(pll->base, PLLCTRL_PLL_CONTROL, pll_feat->sys_reset, 3, 3); /* READ 0x0 reset is in progress */ if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_STATUS, 0, 0, 1) @@ -195,11 +216,58 @@ void hdmi_pll_disable(struct hdmi_pll_data *pll, struct hdmi_wp_data *wp) #define PLL_OFFSET 0x200 #define PLL_SIZE 0x100 +static const struct hdmi_pll_features omap44xx_pll_feats = { + .sys_reset = false, + .bound_dcofreq = false, +}; + +static const struct hdmi_pll_features omap54xx_pll_feats = { + .sys_reset = true, + .bound_dcofreq = true, +}; + +static int __init hdmi_pll_init_features(struct platform_device *pdev) +{ + struct hdmi_pll_features *dst; + const struct hdmi_pll_features *src; + + dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); + if (!dst) { + dev_err(&pdev->dev, "Failed to allocate HDMI PHY Features\n"); + return -ENOMEM; + } + + switch (omapdss_get_version()) { + case OMAPDSS_VER_OMAP4430_ES1: + case OMAPDSS_VER_OMAP4430_ES2: + case OMAPDSS_VER_OMAP4: + src = &omap44xx_pll_feats; + break; + + case OMAPDSS_VER_OMAP5: + src = &omap54xx_pll_feats; + break; + + default: + return -ENODEV; + } + + memcpy(dst, src, sizeof(*dst)); + pll_feat = dst; + + return 0; +} + int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll) { + int r; struct resource *res; struct resource temp_res; + r = hdmi_pll_init_features(pdev); + if (r) + return r; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi_pllctrl"); if (!res) { DSSDBG("can't get PLL mem resource by name\n");