From patchwork Tue Jul 2 15:47:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier MOYSAN X-Patchwork-Id: 11028185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B31C17E0 for ; Tue, 2 Jul 2019 15:48:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 004B928984 for ; Tue, 2 Jul 2019 15:48:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8B1E28985; Tue, 2 Jul 2019 15:48:57 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A23A28986 for ; Tue, 2 Jul 2019 15:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TibPwgliitFuSvot7XWNJucEB4w6JM3HI7/lCl9Q1bw=; b=fkrAaJrCgdGSL7 07G3rBuqcR6ZieegKlEPriYqhNjHbMoEiOxqMGIc9F4iPX0lTEIZ/qEz+7AI97V6WPSDhOEkJPlW5 RTZHDjYpILrtFX0qMYxs1ursiwdGz+MAvXthtJXImitQrrTF/obJbSGQ0BXj6D+Itey3TUrDVPXx4 XojdyKQacHHTHMSrFWQtkaRQVX5tbx8oCE/i4cBL1Ubbbw/h9xFZAuCU0AqpzDcfp9KWygXpa+o7Z F8m0x5qMpYcnLoj29d+2Y/ZfvHusp2GCnZcu/L0wdtRUMTurKsow46j3g2C29mAlMbV+f+4EdO/ii necth0hP6FbkgcWaOeIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hiL1X-0001Zl-Kd; Tue, 02 Jul 2019 15:48:51 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiL0j-0000tw-SZ for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2019 15:48:03 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x62Fl4xI003868; Tue, 2 Jul 2019 17:47:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=QNrE+/1IDPSo8HmO50ipNpLfEJf8OZLuIag97CDeCZo=; b=DbtBWM33Xxy7Hydeg0QFgBwYitsXMTubI8ucCw89x9WjLZKbnFZ7mbxtsOSgVyluo704 iAvWpy9uq+IUaOofmgMPubkhXIr5hsx2Gfg+X5DEVnVwYksp+gMSDZ2thmY8kEt8KKi9 B80z/cp3KOnEq+aZojPcI08t4Lv6LaPS+XLPCN1cB9iAlUryEiG/YiLURp5Fu9vV2Mia Rm0cndJf6JKuSaWreaFHHR3Tk4pNhE4N0kHG4X4UjGIP9/06qjHnahTv35+yCf93rkdV iQZtQzqMiBOALxeSSAymLgHI2mTm5b5vB4wyIZdaY6sd2Sgf3VF6EsN1uWQcwzLP7wg0 Sg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2tdw49wfwm-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 02 Jul 2019 17:47:42 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3F9C331; Tue, 2 Jul 2019 15:47:41 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0A148487E; Tue, 2 Jul 2019 15:47:41 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 17:47:41 +0200 Received: from localhost (10.201.23.16) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 17:47:40 +0200 From: Olivier Moysan To: , , , , , , , , , , , , , , , , , Subject: [PATCH 3/3] drm/bridge: sii902x: make audio mclk optional Date: Tue, 2 Jul 2019 17:47:06 +0200 Message-ID: <1562082426-14876-4-git-send-email-olivier.moysan@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1562082426-14876-1-git-send-email-olivier.moysan@st.com> References: <1562082426-14876-1-git-send-email-olivier.moysan@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.16] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-02_08:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_084802_205829_9942838E X-CRM114-Status: GOOD ( 15.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The master clock on i2s bus is not mandatory, as sii902X internal PLL can be used instead. Make use of mclk optional. Fixes: ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support") Signed-off-by: Olivier Moysan Reviewed-by: Jyri Sarha Reviewed-by: Philippe Cornu Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/bridge/sii902x.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c index 36acc256e67e..a08bd9fdc046 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -562,19 +562,21 @@ static int sii902x_audio_hw_params(struct device *dev, void *data, } } - ret = clk_prepare_enable(sii902x->audio.mclk); - if (ret) { - dev_err(dev, "Enabling mclk failed: %d\n", ret); - return ret; - } + if (sii902x->audio.mclk) { + ret = clk_prepare_enable(sii902x->audio.mclk); + if (ret) { + dev_err(dev, "Enabling mclk failed: %d\n", ret); + return ret; + } - mclk_rate = clk_get_rate(sii902x->audio.mclk); + mclk_rate = clk_get_rate(sii902x->audio.mclk); - ret = sii902x_select_mclk_div(&i2s_config_reg, params->sample_rate, - mclk_rate); - if (mclk_rate != ret * params->sample_rate) - dev_dbg(dev, "Inaccurate reference clock (%ld/%d != %u)\n", - mclk_rate, ret, params->sample_rate); + ret = sii902x_select_mclk_div(&i2s_config_reg, + params->sample_rate, mclk_rate); + if (mclk_rate != ret * params->sample_rate) + dev_dbg(dev, "Inaccurate reference clock (%ld/%d != %u)\n", + mclk_rate, ret, params->sample_rate); + } mutex_lock(&sii902x->mutex); @@ -640,7 +642,8 @@ static int sii902x_audio_hw_params(struct device *dev, void *data, mutex_unlock(&sii902x->mutex); if (ret) { - clk_disable_unprepare(sii902x->audio.mclk); + if (sii902x->audio.mclk) + clk_disable_unprepare(sii902x->audio.mclk); dev_err(dev, "%s: hdmi audio enable failed: %d\n", __func__, ret); } @@ -659,7 +662,8 @@ static void sii902x_audio_shutdown(struct device *dev, void *data) mutex_unlock(&sii902x->mutex); - clk_disable_unprepare(sii902x->audio.mclk); + if (sii902x->audio.mclk) + clk_disable_unprepare(sii902x->audio.mclk); } int sii902x_audio_digital_mute(struct device *dev, void *data, bool enable) @@ -752,9 +756,12 @@ static int sii902x_audio_codec_init(struct sii902x *sii902x, sii902x->audio.mclk = devm_clk_get(dev, "mclk"); if (IS_ERR(sii902x->audio.mclk)) { - dev_err(dev, "%s: No clock (audio mclk) found: %ld\n", - __func__, PTR_ERR(sii902x->audio.mclk)); - return 0; + if (PTR_ERR(sii902x->audio.mclk) != -ENOENT) { + dev_err(dev, "%s: No clock (audio mclk) found: %ld\n", + __func__, PTR_ERR(sii902x->audio.mclk)); + return PTR_ERR(sii902x->audio.mclk); + } + sii902x->audio.mclk = NULL; } sii902x->audio.pdev = platform_device_register_data(