Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4842321pxu; Thu, 10 Dec 2020 06:50:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHedp5Q4M3B5amV5d9bBT3FdiMViPSwk8+3PHs/Z/grm5oZdQeMplvrW4vPx+rBQDfbGap X-Received: by 2002:a17:906:7f0b:: with SMTP id d11mr6829958ejr.7.1607611847263; Thu, 10 Dec 2020 06:50:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607611847; cv=none; d=google.com; s=arc-20160816; b=XL9/QUS6nyahwX0J1oZXOXeoaGrJm+W/w8zycF6lG3Yu1XAu/+LiXzm3mphDU70HiI SnzcAAmOwTKZ8iTKSsbK0HCsOvEShoVXibCWkChn3Wm8Az+5acsIW7nWWCjDJ/nlT0rc /7occ3dJSeakEUy5CGkkGLHfmLOgNcWRGyy79cjHMNPU/B9XWF0aa0afO/upmsL0+AJJ mWC5Mg9sBpT6BUC9PgapBJ3u6V3vLH6c9MOwLBG0w4FGB7CwI0N1tKi5S/Un+gE6/xs4 /q7gQvBsg9nD7bHhyt4Ej+hPVE4E0SCSYkwwG4M5cdtAUPalkP1hkTp4FIiflXPg4V2t +waA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=GnMDKUbYk1SWYyZetGWDdJskWJOGEDSUZizDVtCEfAo=; b=ALFFxBOBnBySI58SzpAgKr4+gH2XwhpDbpYUzpWEGsD4BEKxlTGBC90k7iUw3+12qp /WFUFiuDtrHsNzS3/D6oxVllzAB95vaEmFEQyFLVoytraR/8YkcTUcZ5zw5jEJsSkKAa yJohPPw0bV6OoJZ+Ww8DddUw6g1qevj5TVhaJYEoi8oRhNorigPliBKLByo809ICcGcM y02eypPk4E8YZWC+Ma61YLZ5EVBtCPEbS3gA0OgZxi5RZTDJ2g3IgvmJGaPVYnMOF3a3 VoDRXxk1dkJo+WrHVv/IqPpydVFr7YQGWYeTB2QNlbvsoGYc3cTqbg7Q+GAVEmpTUCtX VM3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm1 header.b=Omnj0xdM; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=gCa43CV7; 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=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y26si2947142edo.273.2020.12.10.06.50.24; Thu, 10 Dec 2020 06:50:47 -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=@cerno.tech header.s=fm1 header.b=Omnj0xdM; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=gCa43CV7; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389667AbgLJNyC (ORCPT + 99 others); Thu, 10 Dec 2020 08:54:02 -0500 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:52827 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389331AbgLJNsv (ORCPT ); Thu, 10 Dec 2020 08:48:51 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 060F642D; Thu, 10 Dec 2020 08:46:59 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 10 Dec 2020 08:47:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=GnMDKUbYk1SWY yZetGWDdJskWJOGEDSUZizDVtCEfAo=; b=Omnj0xdM/OiaRxShbBIW4aFeaaRa9 4Ib3cLiJ29OyceCsrvFP3eiRNZcs/HPszUD9/ukJXiP0IlEJs1+DnOOQ4/N6h1Sp r4fsXDlMxqdyIx6laZwxMUfgd5N80E2wbBdQHgLp7gNiraOJvOLwxth4kXW65jXD VPGDXTayRawqTjX144lJMvDsQmbCEknYNNeY65MrHtBEs5lny1wFoLMUMpqlqmWC TXX6aSLY1SuuPHCSfjf54hBoi37X6AxP8EwGZJaJ8gEXdg87CQkYnHRImXL7e1kY kr3klWULgU7IxDcLA/TxVE5tmBe57+edAHA00Tgc3rz9OjpsRFrMyTPRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=GnMDKUbYk1SWYyZetGWDdJskWJOGEDSUZizDVtCEfAo=; b=gCa43CV7 uj4WkRzFvbg5OzFv72wwcYqk003p3HQElHwH82Kc8IesIE1HOdD57EU/7fTofamA zKaR95/2Jrli7RrZWfP0IRqWY5aMid1jIAa9w1MgQkIAFvy3LhzR1BtcrKHkGC3o 4bc29xBEuzYPd002RNr2eDlGTAy/eDbWQZ0RAJMGgIXpMWd6aNMD2pIUPKDUiPKo cdTRYox5otctKooC0zstwIthlMpFltI91KKDBVX90CMhUQWXbxUVvQLp4R7DV0Tk VjhZHOOBafwCXCQb4p7VnR8iXZuIuk5adn9ooYwdEGaeG/wZQm8iYkHJ0wNBQrlo gPsXzMn017OOYg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudektddgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 66AF81080059; Thu, 10 Dec 2020 08:46:59 -0500 (EST) From: Maxime Ripard To: Eric Anholt , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie Cc: Jason Cooper , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, Marc Zyngier , linux-media@vger.kernel.org, Hans Verkuil , linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Thomas Gleixner , Dave Stevenson , linux-rpi-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH 07/15] drm/vc4: hdmi: Update the CEC clock divider on HSM rate change Date: Thu, 10 Dec 2020 14:46:40 +0100 Message-Id: <20201210134648.272857-8-maxime@cerno.tech> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201210134648.272857-1-maxime@cerno.tech> References: <20201210134648.272857-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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