Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp611838pxb; Wed, 3 Mar 2021 10:43:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaAuvqBgtkCvSGd62l6/rHL4spKryXv0tVJ9GmbnNM0q9Vtx5upMbMouLBjNgvnCwgxqbp X-Received: by 2002:a05:6402:208:: with SMTP id t8mr667371edv.189.1614796985734; Wed, 03 Mar 2021 10:43:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614796985; cv=none; d=google.com; s=arc-20160816; b=Ap/jTt6/6YMl/0nM39G3sPj5wgCyE/ZUS8M75KM/axphXT5YvYrXjrTAvWkr0sNPRH qpy1Ot7S2KKh5ki74cxRF479rxL8i1RXlGTQ6Zfaf934TzIHHZP4vrVKqU3OISsortXu AhpOMISunSHwKN0MPSxSg+kAwEEzXBCAP17T5UXHvGpyWGaRGjPELpLZvtZ1XbqJFxOc /E8JWx6jJPHpiDQKfrGyXLxWxfNUm5cP0xnt4Upbstypk5nfMH1evR60exIuFcJHYH7q VbZrKozztoViEGbArN2S0leKGzDY7oz51bz1TdFgpUu93lWUl7tUeRe+uzBzOSzSIZQD LfSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9VDPhfLcsssPMZdjLcFEvS+EkYVetiHXwVUbatOJ5iE=; b=za47Xe25NSjtB/AMWCDek9RIW3+tDz6BxGAU//YnVtBv2oZWBgI3ZsBud9sozCw7NO G7LrPH4pzfqOJHRBNCy9GTn5GblIepKvApAtGqPFdWHIq3V8IBMt4r+ZIFrTCzf+v4Vk PVfsWuO6wwGkw6ap7FTJyRZ3aP8myUFNuwjD3E/9zx56LjgGnjPqqyP8IPFQOEatxa3j 8j4G4iiV5m0C4KzNVUmXjPdrPipX3mSEtuiPyfNguipHcAFyJwjnGk7OaPYNx3sL5cjp Ppnk/CiI9qqUhp+yIM2HqlzLiwnRUUJfDwJ9RpXlslfxjKN8aNRC9M9Me+ZNWuN5XPYe T5nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iyyaw9I1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si3996535ejs.219.2021.03.03.10.42.33; Wed, 03 Mar 2021 10:43:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iyyaw9I1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378409AbhCBBF5 (ORCPT + 99 others); Mon, 1 Mar 2021 20:05:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:34916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240801AbhCATBA (ORCPT ); Mon, 1 Mar 2021 14:01:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6681B64F46; Mon, 1 Mar 2021 17:15:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618916; bh=j1Q1T63eINs/3s64OsPlzq+a4ciRHKucyGez2lTkyp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iyyaw9I1tqkTV3qcZPQQDhcheoT+KNN4+5HI/FfS8L1BMVwpMDkA/tOeeQzSFXwMD DqldwlrLiOST2oP29BvNS2qbh88zYj9bVlchHbLgB0OTXpVEJAVGdTX+FYOnhjZw47 iKp0rWRrb93/3jNEHyAsxHTtuWMNSjYKyXDHX3fo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Stevenson , Maxime Ripard , Hans Verkuil , Maarten Lankhorst , Sasha Levin Subject: [PATCH 5.10 234/663] drm/vc4: hdmi: Update the CEC clock divider on HSM rate change Date: Mon, 1 Mar 2021 17:08:02 +0100 Message-Id: <20210301161153.389730750@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxime Ripard [ Upstream commit 47fa9a80270e20a0c4ddaffca1f144d22cc59620 ] As part of the enable sequence we might change the HSM clock rate if the pixel rate is different than the one we were already dealing with. On the BCM2835 however, the CEC clock derives from the HSM clock so any rate change will need to be reflected in the CEC clock divider to output 40kHz. Fixes: cd4cb49dc5bb ("drm/vc4: hdmi: Adjust HSM clock rate depending on pixel rate") Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard Acked-by: Hans Verkuil Tested-by: Hans Verkuil Link: https://patchwork.freedesktop.org/patch/msgid/20210111142309.193441-8-maxime@cerno.tech (cherry picked from commit a9dd0b9a5c3e11c79e6ff9c7fdf07c471732dcb6) Signed-off-by: Maarten Lankhorst Signed-off-by: Sasha Levin --- drivers/gpu/drm/vc4/vc4_hdmi.c | 39 +++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 08b3f9c87e6ec..af5f01eff872c 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -119,6 +119,27 @@ static void vc5_hdmi_reset(struct vc4_hdmi *vc4_hdmi) HDMI_READ(HDMI_CLOCK_STOP) | VC4_DVP_HT_CLOCK_STOP_PIXEL); } +#ifdef CONFIG_DRM_VC4_HDMI_CEC +static void vc4_hdmi_cec_update_clk_div(struct vc4_hdmi *vc4_hdmi) +{ + u16 clk_cnt; + u32 value; + + value = HDMI_READ(HDMI_CEC_CNTRL_1); + value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK; + + /* + * Set the clock divider: the hsm_clock rate and this divider + * setting will give a 40 kHz CEC clock. + */ + clk_cnt = clk_get_rate(vc4_hdmi->hsm_clock) / CEC_CLOCK_FREQ; + value |= clk_cnt << VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT; + HDMI_WRITE(HDMI_CEC_CNTRL_1, value); +} +#else +static void vc4_hdmi_cec_update_clk_div(struct vc4_hdmi *vc4_hdmi) {} +#endif + static enum drm_connector_status vc4_hdmi_connector_detect(struct drm_connector *connector, bool force) { @@ -652,6 +673,8 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder) return; } + vc4_hdmi_cec_update_clk_div(vc4_hdmi); + /* * FIXME: When the pixel freq is 594MHz (4k60), this needs to be setup * at 300MHz. @@ -1468,7 +1491,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi) { struct cec_connector_info conn_info; struct platform_device *pdev = vc4_hdmi->pdev; - u16 clk_cnt; u32 value; int ret; @@ -1487,17 +1509,14 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi) cec_s_conn_info(vc4_hdmi->cec_adap, &conn_info); HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, 0xffffffff); + value = HDMI_READ(HDMI_CEC_CNTRL_1); - value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK; - /* - * Set the logical address to Unregistered and set the clock - * divider: the hsm_clock rate and this divider setting will - * give a 40 kHz CEC clock. - */ - clk_cnt = clk_get_rate(vc4_hdmi->hsm_clock) / CEC_CLOCK_FREQ; - value |= VC4_HDMI_CEC_ADDR_MASK | - (clk_cnt << VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT); + /* Set the logical address to Unregistered */ + value |= VC4_HDMI_CEC_ADDR_MASK; HDMI_WRITE(HDMI_CEC_CNTRL_1, value); + + vc4_hdmi_cec_update_clk_div(vc4_hdmi); + ret = devm_request_threaded_irq(&pdev->dev, platform_get_irq(pdev, 0), vc4_cec_irq_handler, vc4_cec_irq_handler_thread, 0, -- 2.27.0