From patchwork Tue Jun 28 15:44:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Abreu X-Patchwork-Id: 9204189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92E3360757 for ; Wed, 29 Jun 2016 01:06:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AF7628339 for ; Wed, 29 Jun 2016 01:06:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DD112862E; Wed, 29 Jun 2016 01:06:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5519528339 for ; Wed, 29 Jun 2016 01:06:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A74E36E66E; Wed, 29 Jun 2016 01:06:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtprelay.synopsys.com (smtprelay.synopsys.com [198.182.47.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FD3E89415 for ; Tue, 28 Jun 2016 15:44:24 +0000 (UTC) Received: from us02secmta2.synopsys.com (us02secmta2.synopsys.com [10.12.235.98]) by smtprelay.synopsys.com (Postfix) with ESMTP id 3BCF224E0B85; Tue, 28 Jun 2016 08:44:23 -0700 (PDT) Received: from us02secmta2.internal.synopsys.com (us02secmta2.internal.synopsys.com [127.0.0.1]) by us02secmta2.internal.synopsys.com (Service) with ESMTP id 0A1A655F13; Tue, 28 Jun 2016 08:44:23 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by us02secmta2.internal.synopsys.com (Service) with ESMTP id A867455F02; Tue, 28 Jun 2016 08:44:22 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 8BEC8534; Tue, 28 Jun 2016 08:44:22 -0700 (PDT) Received: from synopsys-Macmini.internal.synopsys.com (synopsys-macmini.internal.synopsys.com [10.107.25.130]) by mailhost.synopsys.com (Postfix) with ESMTP id 3BBE952D; Tue, 28 Jun 2016 08:44:20 -0700 (PDT) From: Jose Abreu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm: bridge/dw-hdmi: Add support for DWC Phy Date: Tue, 28 Jun 2016 16:44:12 +0100 Message-Id: <57670f5135c25437f7cc31e1554059545f956026.1467128266.git.joabreu@synopsys.com> X-Mailer: git-send-email 2.1.4 X-Mailman-Approved-At: Wed, 29 Jun 2016 01:06:22 +0000 Cc: Jose Abreu , Fabio Estevam , Daniel Vetter , Carlos Palminha , linux-kernel@vger.kernel.org, Russell King , Thierry Reding , Vladimir Zapolskiy X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for the Synopsys HDMI TX Phy in bridge dw-hdmi. The init flow is the same as the Rockchip Phy so we only need to add one define and one if statement. Also, the audio infoframe was fixed to sampling frequency of 44.1k. With this patch this is now corrected. As I don't know if this is specific to Synopsys Phy we only set this if Phy type is DWC_HDMI. Signed-off-by: Jose Abreu Cc: Carlos Palminha Cc: David Airlie Cc: Russell King Cc: Fabio Estevam Cc: Daniel Vetter Cc: Takashi Iwai Cc: Vladimir Zapolskiy Cc: Thierry Reding Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- Changes v1 -> v2: - Fixed Audio Infoframe drivers/gpu/drm/bridge/dw-hdmi.c | 25 ++++++++++++++++++++++++- drivers/gpu/drm/bridge/dw-hdmi.h | 1 + include/drm/bridge/dw_hdmi.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index c9d9412..2cab188 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -215,6 +215,29 @@ static void hdmi_set_cts_n(struct dw_hdmi *hdmi, unsigned int cts, hdmi_writeb(hdmi, (n >> 16) & 0x0f, HDMI_AUD_N3); hdmi_writeb(hdmi, (n >> 8) & 0xff, HDMI_AUD_N2); hdmi_writeb(hdmi, n & 0xff, HDMI_AUD_N1); + + /* Set Frame Composer Audio Sample sampling frequency */ + if (hdmi->dev_type == DWC_HDMI) { + u8 val = 0x0; + + switch (hdmi->sample_rate) { + case 320000: + val = 0x3; + break; + case 441000: + val = 0x0; + break; + case 480000: + val = 0x2; + break; + default: + dev_err(hdmi->dev, "unsupported sample rate (%d)\n", + hdmi->sample_rate); + return; + } + + hdmi_writeb(hdmi, val, HDMI_FC_AUDSCHNL7); + } } static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) @@ -833,7 +856,7 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, unsigned char prep, dw_hdmi_phy_gen2_txpwron(hdmi, 1); dw_hdmi_phy_gen2_pddq(hdmi, 0); - if (hdmi->dev_type == RK3288_HDMI) + if ((hdmi->dev_type == RK3288_HDMI) || (hdmi->dev_type == DWC_HDMI)) dw_hdmi_phy_enable_spare(hdmi, 1); /*Wait for PHY PLL lock */ diff --git a/drivers/gpu/drm/bridge/dw-hdmi.h b/drivers/gpu/drm/bridge/dw-hdmi.h index fc9a560..5f137fd 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.h +++ b/drivers/gpu/drm/bridge/dw-hdmi.h @@ -162,6 +162,7 @@ #define HDMI_FC_SPDDEVICEINF 0x1062 #define HDMI_FC_AUDSCONF 0x1063 #define HDMI_FC_AUDSSTAT 0x1064 +#define HDMI_FC_AUDSCHNL7 0x106E #define HDMI_FC_DATACH0FILL 0x1070 #define HDMI_FC_DATACH1FILL 0x1071 #define HDMI_FC_DATACH2FILL 0x1072 diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index bae79f3..6e4fb2e 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -25,6 +25,7 @@ enum dw_hdmi_devtype { IMX6Q_HDMI, IMX6DL_HDMI, RK3288_HDMI, + DWC_HDMI, }; struct dw_hdmi_mpll_config {