Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp599413pxb; Thu, 19 Aug 2021 07:03:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5T2r48Q79hthu5s+MwlnmmjigI5KjQP59dH7C5AEbXyuXBVmIx5ZQI/h39kwX09j2cd/a X-Received: by 2002:a05:6638:2284:: with SMTP id y4mr13521020jas.75.1629381792148; Thu, 19 Aug 2021 07:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629381792; cv=none; d=google.com; s=arc-20160816; b=HnL9SbecR4hJlLpq5j6XtGVV+sM2VHjZQqUXQi9buXrqhLyvtM2UGaDaM18OrjN500 L3XgRlV4jSJw+4hyAmSRvHdrwy7F4Q/pfOQfWQf0ymjgB2ns2Fpv1LiA5Vbk5nNBNzY1 c9v0jG4mm/FTO9U6OLL6UaOMVm56vTr2olpZx0/br1PvMArceTmCnjdKh2eOMWSC9Ok7 TbJ8D4CzdW4q1TqIGEMh/k6slzMfTBp+7QRYeSu8tg8jigkHZQ3RWpMmpzYGPsR29FtR gE28oe6sidUW9XMjQCq678VHn9o9/TjdrIXV4gcB2+AvNG89jZZbi7HTrl7pg6/3Alt8 v2yg== 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=gKXF5nLq9rUn2jzx/vOAy6T3H6ZUjYqDazxAlaD6/5k=; b=y4VwNM4d9v0lHwzpsp3aVAug0twjgf4tL/oTHOwIHf1Ea/HTQIPkr6pOm615l0qPMU 9MiV7iGjnq7EA8MbNzSbVferMvdsN7q2LojYiTq0zCB3Pa9VM2rEgP8fsooPro2hJUS5 6Y3B+pnXd5WxkfQ3ZTvsrtt9L+FzbeqNuav8BbItQAYNEDKalVRmag1mpoPxkjFiCeF2 Ct/exJADCXCwLlGdRInJX4COQrz+hMZJVND0Ntzoexl+ZD3iv+zMQC0MbZ5xmfohGI2y veIAJbwFJq3jf09DppQ698GYxENppFefBXp5ZqkFg3TjKKpuuFmGWGLRecsLDda8/abt +RTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=z5bYMddu; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=JiLwp5Om; 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 t7si3223565jah.88.2021.08.19.07.02.58; Thu, 19 Aug 2021 07:03:12 -0700 (PDT) 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=fm3 header.b=z5bYMddu; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=JiLwp5Om; 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 S240452AbhHSOAc (ORCPT + 99 others); Thu, 19 Aug 2021 10:00:32 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:55811 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240439AbhHSOAb (ORCPT ); Thu, 19 Aug 2021 10:00:31 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 38E5F2B00560; Thu, 19 Aug 2021 09:59:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 19 Aug 2021 09:59:55 -0400 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=fm3; bh=gKXF5nLq9rUn2 jzx/vOAy6T3H6ZUjYqDazxAlaD6/5k=; b=z5bYMddu5cs8nClLEU09yvcMdomUz YNJ4vaHxPIQHqR0yFRVNphCKKAgU2kAQmOo6r6qR3Hkjr85ZPsp2hGtTQTGPAZFF bveqlQtmaAktYk1opkx9XOmPQnZhHRd6JYm7qh5Q7xZ6USXT/Asd9h7ueLapBwXS 1+rlCbx9IxgdGZw2ac1blPwfy2JbhfCXBebn57KL22/SOYZa8bUg1h3ITmxDLxgA t1gTwOhXLP94/IIvjywAhEoURDGtt8IHlkDfOyWlRrR/NVio14W1fThEFScYkXzW aEYMiRFBrLYfFQrlafJkh9VRwOSA5gavN155AXdte828N04wzdm87zweA== 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= fm3; bh=gKXF5nLq9rUn2jzx/vOAy6T3H6ZUjYqDazxAlaD6/5k=; b=JiLwp5Om Nw0yw38pAPQXN091eX9VVjUdUGW7uPnTmHmLkf490dqAEh0f5BDQvmpKcpvixLkV 6ofJ620pAEtBMG1wkLK2AcFoBKeoVD9myl8MzhGw7cWvAGHy9PbnGJQu+biEQnrz RCk28QkywV1Gt1LpF4tZjzvXRGsWPUDoDm9sjlcffL5LwyDqq34I9yylk/Tp0Wsr o4yzYH8EyAgkUI67nlKOaKMQEfbov0ZrZiq7/Ad0oTgFE+Ipu+IjdZ3CfZ7vhueP 1VMwsRApp4/zBYqQlba5y47LZ7PcbOqC2k7sC4Kd3x7P9YlYEmk7EsYr7qIyWFOP u8en/n7VRFpcKw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrleejgdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Aug 2021 09:59:52 -0400 (EDT) From: Maxime Ripard To: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Cc: linux-kernel@vger.kernel.org, Dave Stevenson , Phil Elwell , Tim Gover , Dom Cobley , Boris Brezillon , linux-rpi-kernel@lists.infradead.org, Hans Verkuil , bcm-kernel-feedback-list@broadcom.com, Emma Anholt , Nicolas Saenz Julienne , Maxime Ripard Subject: [PATCH v3 4/6] drm/vc4: hdmi: Split the CEC disable / enable functions in two Date: Thu, 19 Aug 2021 15:59:29 +0200 Message-Id: <20210819135931.895976-5-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819135931.895976-1-maxime@cerno.tech> References: <20210819135931.895976-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to ease further additions to the CEC enable and disable, let's split the function into two functions, one to enable and the other to disable. Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 73 ++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 8458f38e2883..bfa35e32052f 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1740,7 +1740,7 @@ static irqreturn_t vc4_cec_irq_handler(int irq, void *priv) return ret; } -static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) +static int vc4_hdmi_cec_enable(struct cec_adapter *adap) { struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); /* clock period in microseconds */ @@ -1753,38 +1753,53 @@ static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) val |= ((4700 / usecs) << VC4_HDMI_CEC_CNT_TO_4700_US_SHIFT) | ((4500 / usecs) << VC4_HDMI_CEC_CNT_TO_4500_US_SHIFT); - if (enable) { - HDMI_WRITE(HDMI_CEC_CNTRL_5, val | - VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET); - HDMI_WRITE(HDMI_CEC_CNTRL_5, val); - HDMI_WRITE(HDMI_CEC_CNTRL_2, - ((1500 / usecs) << VC4_HDMI_CEC_CNT_TO_1500_US_SHIFT) | - ((1300 / usecs) << VC4_HDMI_CEC_CNT_TO_1300_US_SHIFT) | - ((800 / usecs) << VC4_HDMI_CEC_CNT_TO_800_US_SHIFT) | - ((600 / usecs) << VC4_HDMI_CEC_CNT_TO_600_US_SHIFT) | - ((400 / usecs) << VC4_HDMI_CEC_CNT_TO_400_US_SHIFT)); - HDMI_WRITE(HDMI_CEC_CNTRL_3, - ((2750 / usecs) << VC4_HDMI_CEC_CNT_TO_2750_US_SHIFT) | - ((2400 / usecs) << VC4_HDMI_CEC_CNT_TO_2400_US_SHIFT) | - ((2050 / usecs) << VC4_HDMI_CEC_CNT_TO_2050_US_SHIFT) | - ((1700 / usecs) << VC4_HDMI_CEC_CNT_TO_1700_US_SHIFT)); - HDMI_WRITE(HDMI_CEC_CNTRL_4, - ((4300 / usecs) << VC4_HDMI_CEC_CNT_TO_4300_US_SHIFT) | - ((3900 / usecs) << VC4_HDMI_CEC_CNT_TO_3900_US_SHIFT) | - ((3600 / usecs) << VC4_HDMI_CEC_CNT_TO_3600_US_SHIFT) | - ((3500 / usecs) << VC4_HDMI_CEC_CNT_TO_3500_US_SHIFT)); + HDMI_WRITE(HDMI_CEC_CNTRL_5, val | + VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET); + HDMI_WRITE(HDMI_CEC_CNTRL_5, val); + HDMI_WRITE(HDMI_CEC_CNTRL_2, + ((1500 / usecs) << VC4_HDMI_CEC_CNT_TO_1500_US_SHIFT) | + ((1300 / usecs) << VC4_HDMI_CEC_CNT_TO_1300_US_SHIFT) | + ((800 / usecs) << VC4_HDMI_CEC_CNT_TO_800_US_SHIFT) | + ((600 / usecs) << VC4_HDMI_CEC_CNT_TO_600_US_SHIFT) | + ((400 / usecs) << VC4_HDMI_CEC_CNT_TO_400_US_SHIFT)); + HDMI_WRITE(HDMI_CEC_CNTRL_3, + ((2750 / usecs) << VC4_HDMI_CEC_CNT_TO_2750_US_SHIFT) | + ((2400 / usecs) << VC4_HDMI_CEC_CNT_TO_2400_US_SHIFT) | + ((2050 / usecs) << VC4_HDMI_CEC_CNT_TO_2050_US_SHIFT) | + ((1700 / usecs) << VC4_HDMI_CEC_CNT_TO_1700_US_SHIFT)); + HDMI_WRITE(HDMI_CEC_CNTRL_4, + ((4300 / usecs) << VC4_HDMI_CEC_CNT_TO_4300_US_SHIFT) | + ((3900 / usecs) << VC4_HDMI_CEC_CNT_TO_3900_US_SHIFT) | + ((3600 / usecs) << VC4_HDMI_CEC_CNT_TO_3600_US_SHIFT) | + ((3500 / usecs) << VC4_HDMI_CEC_CNT_TO_3500_US_SHIFT)); + + if (!vc4_hdmi->variant->external_irq_controller) + HDMI_WRITE(HDMI_CEC_CPU_MASK_CLEAR, VC4_HDMI_CPU_CEC); - if (!vc4_hdmi->variant->external_irq_controller) - HDMI_WRITE(HDMI_CEC_CPU_MASK_CLEAR, VC4_HDMI_CPU_CEC); - } else { - if (!vc4_hdmi->variant->external_irq_controller) - HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, VC4_HDMI_CPU_CEC); - HDMI_WRITE(HDMI_CEC_CNTRL_5, val | - VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET); - } return 0; } +static int vc4_hdmi_cec_disable(struct cec_adapter *adap) +{ + struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); + + if (!vc4_hdmi->variant->external_irq_controller) + HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, VC4_HDMI_CPU_CEC); + + HDMI_WRITE(HDMI_CEC_CNTRL_5, HDMI_READ(HDMI_CEC_CNTRL_5) | + VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET); + + return 0; +} + +static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) +{ + if (enable) + return vc4_hdmi_cec_enable(adap); + else + return vc4_hdmi_cec_disable(adap); +} + static int vc4_hdmi_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr) { struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); -- 2.31.1