Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2140158pxu; Fri, 18 Dec 2020 06:31:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPrsNPmWfCowPYSi5L45uiC89lerBWPr6uzpuUxBKolYV9DTIjxyIH9SiqOn+bVTrgJPls X-Received: by 2002:a17:906:ae14:: with SMTP id le20mr4307728ejb.451.1608301873074; Fri, 18 Dec 2020 06:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608301873; cv=none; d=google.com; s=arc-20160816; b=UihgPjE91RfDSbRqLKXkM/M8IpWDqVH+9E6Nj6fo8mPjNxhPVss5q8RyUcYikSqqjq iplKULoqEHmmG5NKc9Zga3tLwbLFhedEbx3wPAGBKdWC4QqwdTVmCNEj3uA1CwuSZzL4 wVO2cpQ+12q0DLRBbuqtvcxoNfFmhhMH3t0zS8WwgvnC+fx5mxXUh9fWWq46bv+M7MlQ rSt+uRG4x/VRi+I7ezWa/VO1/dENDT57c8ZnwuHJFV5vukRP6zvnKdHKzzBsqxgW8XiA XDtBON88gJ+vS6wc/gQ9doR3AkMRYILNMbiPmFgCb+hGi1Qe+o1TdC/qNCT5gqWFx5Ow 6PCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3jAc8avduUQUrJ7esBOnKUiJwC4FE/zfHKx0EFzGBz4=; b=EzDU4sz7SMVAy4z6hQ1vrH99/LHwO8omsshy1GjlUXBucvx/uW9WZ8ERGQzT++XUuZ v14Q2liA4PHskSgPnfo+XcXIITBWU+SJ+mM8JfavbcvPhMaElTBAzeaDgqMe5xAdi+ge bHjYFTcwXMA2Qp9sBxWtUjpbz+iQX+7QfPuIWnvsdf7ukvadMEv8ny5rjGYJacBFyetN 3jf3lVEsVkxAEnOHv38Kc8rbOxww1muRh8fwGbUx1nbaDdrK9qHVrhn+s26ULMdWPTrF 1kUkLcxZiGdPVvrym/w8eU6o6qqKXHmmAvR7/x2d3AwZDCoov4PiiS42ZMsMW2O14t0g I8Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=F2xfRsnx; 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=raspberrypi.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si4889041ejn.391.2020.12.18.06.30.50; Fri, 18 Dec 2020 06:31:13 -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=@raspberrypi.com header.s=google header.b=F2xfRsnx; 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=raspberrypi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbgLRO14 (ORCPT + 99 others); Fri, 18 Dec 2020 09:27:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgLRO14 (ORCPT ); Fri, 18 Dec 2020 09:27:56 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9638C06138C for ; Fri, 18 Dec 2020 06:27:15 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 190so2524351wmz.0 for ; Fri, 18 Dec 2020 06:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3jAc8avduUQUrJ7esBOnKUiJwC4FE/zfHKx0EFzGBz4=; b=F2xfRsnxvhpv+uKXzfqbx5DcPoqGFopHvfaBoi1q+5mqVAQZxdhyICtkh2j5WfhqO3 3IQecoe1Tv49RuxNLIKuyOjlDOpvEYpmBoOA22StprO4jAKztsbQ7+sOnnguCFjI1OIU zCp17THqkfo1ugcRGSYGkugWd5wKQnG/laLA1EQ2k4gUck1lacj5iwMyIRm41NvG3VVB GHdKvd2sH1ZWm1jABteiUuw+ekkw9Ndlqlmr1VLlCT5qzh+hOGKm7XF4bwxML3TkHtCU LUYLh1XuxOUFyU627821rC71lWA0Jbhr11uUpPI06v5NPJsfZUx6OLC95ABQc83me+oS AWQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3jAc8avduUQUrJ7esBOnKUiJwC4FE/zfHKx0EFzGBz4=; b=hIm1f2IiLbQTBKbo/nMerPkAO7W8NzeVS6Q/tYRMONZS5V9G6HKOT3l7tiiXdUavPv OTAKKH9gYltx5qq0WFXvmPV4vfhVilXWlsS6dF3ePS7lSa5V4iFRrq4vASJAV1GE8lZT mY7tu5GSffoZxMmf8pvHafPYy5uUrGMjXRLX0pjP/j/yrZCff8DgH3xo+4PjlYzMIXo8 oQigTp7BuUVdF1JGulIoJKw+/zHJfVQ54XNbz0V6xp8fK9/nfitwVyGVm8kMmnLTxyxE d1wQaSws7MUsSPmaZyNMyam1l82/hnmpRE4jiyDNGJ4fZ9URpJIzOsp8/bqcYzltbJyO gXHQ== X-Gm-Message-State: AOAM532prCjRFvSxO7+TU/ys919v0HRT6w5fkm6U8uSRdVAMSieAToWs EA4MgMx2rToMBZiYhtZrtgw0Mu7NqISYwy4QHISVJA== X-Received: by 2002:a1c:bc88:: with SMTP id m130mr4637467wmf.82.1608301634416; Fri, 18 Dec 2020 06:27:14 -0800 (PST) MIME-Version: 1.0 References: <20201210134648.272857-1-maxime@cerno.tech> <20201210134648.272857-8-maxime@cerno.tech> In-Reply-To: <20201210134648.272857-8-maxime@cerno.tech> From: Dave Stevenson Date: Fri, 18 Dec 2020 14:26:57 +0000 Message-ID: Subject: Re: [PATCH 07/15] drm/vc4: hdmi: Update the CEC clock divider on HSM rate change To: Maxime Ripard Cc: Eric Anholt , Maarten Lankhorst , Thomas Zimmermann , Daniel Vetter , David Airlie , Jason Cooper , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, Marc Zyngier , Linux Media Mailing List , Hans Verkuil , LKML , Mauro Carvalho Chehab , Thomas Gleixner , linux-rpi-kernel@lists.infradead.org, DRI Development Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime On Thu, 10 Dec 2020 at 13:47, Maxime Ripard wrote: > > 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") > Signed-off-by: Maxime Ripard I thought we'd got a duplicate patch here, but it's moving code that was changed in patch 6/15 so it can be called from vc4_hdmi_encoder_pre_crtc_configure too. Good for confusing me! Reviewed-by: Dave Stevenson > --- > 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 0c53d7427d15..b93ee3e26e2b 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c > @@ -132,6 +132,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) > { > @@ -761,6 +782,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. > @@ -1586,7 +1609,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; > > @@ -1605,17 +1627,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.28.0 >