Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp33935pxu; Thu, 10 Dec 2020 17:24:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJymuqfgYxpewd5RPfjcE8uvij13DK1OQlSfQ3I/aqpEXp0MSu1LF0lCphFO52HUmVmieTSD X-Received: by 2002:a17:907:3e23:: with SMTP id hp35mr9023271ejc.254.1607649881848; Thu, 10 Dec 2020 17:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607649881; cv=none; d=google.com; s=arc-20160816; b=W0iaCOtp7XHO9mlHjmWikBk5ASl2Y9JvQlANIfBpGJ4+cmvGdSdbBm1hROuhTZPPJH oz8c4AOKHFGyEdUpCiUnx7QGA1yzEoN6434rEk6rU1RPrdmNjoR7WTfFGRav+7N2wMTZ BJD2Xh0mFu/OL05nlIISki1S+PCh0YGWDhG0u1FQxA+ldpzcfnvw5m+IVvhXuxQEya+h AgIWfRWV/vAj/tRAKgCmfOr0mPVCHTMxZV523H0F+KCfcXQoy4IZD5TtLcIlVEU73BSE q4bBWqQTkeF7eM9XGUSNvmDgSBXWV922NULxkhUpl8q8AjV+9LjBcTCuLFo/tFiaG0Qf tmOg== 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=3l25+3vkvIlo3zdTOZj26wgphPMfgkDcOOj5Y5/Rn7E=; b=lUahaX/DYyWw3qIjYgWtV/RZsjKTGSt0GvXASy2wzygDZg83UeWxY8ZbofJAuIyjr4 tNNjalLBHXkLe0GZDmxVpx4wUjinNwNoRWSeoNrFOYYUeItYqIQv7o/2F0jhF+55o/Ew MIisfkDp5XgnELXS3V8ZQ5M/fcnuVR90z7PuzC14x405oyHUHGz6gj47PzPVdXIwWjdS wOPqteRtG07zQRIpYZxCauqljHwmdxYrYYmKBmDIwWzensgKiOUc1MYTUNTajH/TBPJt eWwYjje320zjW29E0izf8noGBJS8C1m5Sb3JBgKXO+gN4I90XgbtOvwxIEic3ax2fIfO 35Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm1 header.b="LamlBIu/"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=M8275zfY; 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 p13si3810531edy.540.2020.12.10.17.24.18; Thu, 10 Dec 2020 17:24:41 -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="LamlBIu/"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=M8275zfY; 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 S2389656AbgLJNwg (ORCPT + 99 others); Thu, 10 Dec 2020 08:52:36 -0500 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:35783 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389395AbgLJNtH (ORCPT ); Thu, 10 Dec 2020 08:49:07 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.west.internal (Postfix) with ESMTP id 0C93CEC8; Thu, 10 Dec 2020 08:47:02 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 10 Dec 2020 08:47:04 -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=3l25+3vkvIlo3 zdTOZj26wgphPMfgkDcOOj5Y5/Rn7E=; b=LamlBIu/5hNVwgjfRRnkhX899sXT7 QtJksW123ywwkkfHr+Bk5i2rq3Q/2GUZJ3A+3Ar4SDTvNL+FewfnV+BCDaCIUsIG oNitV6kgJP20/4GKANbzBAfCw5WLTRyzr7VbmjWUmoYW1x4BWqnc+cyf9L7frf2d CMZyifqOHu/NjLePjlSwHEpMCAl3SxmA1imuVLxjREunDQwkcT6sYkz8EF9M9mBl cQwWLyQ8cKJf0YN3vvtkPx1njkHOvONP3N2Wr6n3dN27idNhEljkTXz0lCgoVltA UQh17EMveFf0LAQvcClvh3HDF9umLr0STst3Vspir3Zi2QyIMWne4KrcA== 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=3l25+3vkvIlo3zdTOZj26wgphPMfgkDcOOj5Y5/Rn7E=; b=M8275zfY Tppp2r2eE7oDoA+65vqvb0YpslV51TqC0gKuQ482ydTNFol+Fja8t542xA36lnvX E7uA5rGdcZhAta8/s2czL2jtMPfhvzGg3cJf0vln/E+gvSqnv7c+/HtejT3hzn5h X5pD0o/vCwLpSrDsc/Gk4aFCRa3MXG63H9ibWo1nCVPP9HPfnIaiBr8azyUM7SFu 54SIAKbYHzDWI1BdxLnB+pFRL/P+toNzorEgiZ+UR9F9+T4EXhmAzOuAXhgy9Wl8 m5k/tV3L+IwvsU/1yIpaIkoIaXZFRiVqfm0h979ifMZjhXwS8n5GSEK+Kb+/xWoI u3ubYFhDKRD9rA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudektddgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepudenuc 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 4C82D1080067; Thu, 10 Dec 2020 08:47:02 -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 09/15] drm/vc4: hdmi: Split the interrupt handlers Date: Thu, 10 Dec 2020 14:46:42 +0100 Message-Id: <20201210134648.272857-10-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 The BCM2711 has two different interrupt sources to transmit and receive CEC messages, provided through an external interrupt chip shared between the two HDMI interrupt controllers. The rest of the CEC controller is identical though so we need to change a bit the code organisation to share the code as much as possible, yet still allowing to register independant handlers. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 86 +++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 0debd22bc992..80a81fcea315 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1442,15 +1442,22 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) } #ifdef CONFIG_DRM_VC4_HDMI_CEC -static irqreturn_t vc4_cec_irq_handler_thread(int irq, void *priv) +static irqreturn_t vc4_cec_irq_handler_rx_thread(int irq, void *priv) { struct vc4_hdmi *vc4_hdmi = priv; - if (vc4_hdmi->cec_irq_was_rx) { - if (vc4_hdmi->cec_rx_msg.len) - cec_received_msg(vc4_hdmi->cec_adap, - &vc4_hdmi->cec_rx_msg); - } else if (vc4_hdmi->cec_tx_ok) { + if (vc4_hdmi->cec_rx_msg.len) + cec_received_msg(vc4_hdmi->cec_adap, + &vc4_hdmi->cec_rx_msg); + + return IRQ_HANDLED; +} + +static irqreturn_t vc4_cec_irq_handler_tx_thread(int irq, void *priv) +{ + struct vc4_hdmi *vc4_hdmi = priv; + + if (vc4_hdmi->cec_tx_ok) { cec_transmit_done(vc4_hdmi->cec_adap, CEC_TX_STATUS_OK, 0, 0, 0, 0); } else { @@ -1464,6 +1471,19 @@ static irqreturn_t vc4_cec_irq_handler_thread(int irq, void *priv) return IRQ_HANDLED; } +static irqreturn_t vc4_cec_irq_handler_thread(int irq, void *priv) +{ + struct vc4_hdmi *vc4_hdmi = priv; + irqreturn_t ret; + + if (vc4_hdmi->cec_irq_was_rx) + ret = vc4_cec_irq_handler_rx_thread(irq, priv); + else + ret = vc4_cec_irq_handler_tx_thread(irq, priv); + + return ret; +} + static void vc4_cec_read_msg(struct vc4_hdmi *vc4_hdmi, u32 cntrl1) { struct drm_device *dev = vc4_hdmi->connector.dev; @@ -1488,31 +1508,55 @@ static void vc4_cec_read_msg(struct vc4_hdmi *vc4_hdmi, u32 cntrl1) } } +static irqreturn_t vc4_cec_irq_handler_tx_bare(int irq, void *priv) +{ + struct vc4_hdmi *vc4_hdmi = priv; + u32 cntrl1; + + cntrl1 = HDMI_READ(HDMI_CEC_CNTRL_1); + vc4_hdmi->cec_tx_ok = cntrl1 & VC4_HDMI_CEC_TX_STATUS_GOOD; + cntrl1 &= ~VC4_HDMI_CEC_START_XMIT_BEGIN; + HDMI_WRITE(HDMI_CEC_CNTRL_1, cntrl1); + + return IRQ_WAKE_THREAD; +} + +static irqreturn_t vc4_cec_irq_handler_rx_bare(int irq, void *priv) +{ + struct vc4_hdmi *vc4_hdmi = priv; + u32 cntrl1; + + vc4_hdmi->cec_rx_msg.len = 0; + cntrl1 = HDMI_READ(HDMI_CEC_CNTRL_1); + vc4_cec_read_msg(vc4_hdmi, cntrl1); + cntrl1 |= VC4_HDMI_CEC_CLEAR_RECEIVE_OFF; + HDMI_WRITE(HDMI_CEC_CNTRL_1, cntrl1); + cntrl1 &= ~VC4_HDMI_CEC_CLEAR_RECEIVE_OFF; + + HDMI_WRITE(HDMI_CEC_CNTRL_1, cntrl1); + + return IRQ_WAKE_THREAD; +} + static irqreturn_t vc4_cec_irq_handler(int irq, void *priv) { struct vc4_hdmi *vc4_hdmi = priv; u32 stat = HDMI_READ(HDMI_CEC_CPU_STATUS); - u32 cntrl1, cntrl5; + irqreturn_t ret; + u32 cntrl5; if (!(stat & VC4_HDMI_CPU_CEC)) return IRQ_NONE; - vc4_hdmi->cec_rx_msg.len = 0; - cntrl1 = HDMI_READ(HDMI_CEC_CNTRL_1); + cntrl5 = HDMI_READ(HDMI_CEC_CNTRL_5); vc4_hdmi->cec_irq_was_rx = cntrl5 & VC4_HDMI_CEC_RX_CEC_INT; - if (vc4_hdmi->cec_irq_was_rx) { - vc4_cec_read_msg(vc4_hdmi, cntrl1); - cntrl1 |= VC4_HDMI_CEC_CLEAR_RECEIVE_OFF; - HDMI_WRITE(HDMI_CEC_CNTRL_1, cntrl1); - cntrl1 &= ~VC4_HDMI_CEC_CLEAR_RECEIVE_OFF; - } else { - vc4_hdmi->cec_tx_ok = cntrl1 & VC4_HDMI_CEC_TX_STATUS_GOOD; - cntrl1 &= ~VC4_HDMI_CEC_START_XMIT_BEGIN; - } - HDMI_WRITE(HDMI_CEC_CNTRL_1, cntrl1); + if (vc4_hdmi->cec_irq_was_rx) + ret = vc4_cec_irq_handler_rx_bare(irq, priv); + else + ret = vc4_cec_irq_handler_tx_bare(irq, priv); + HDMI_WRITE(HDMI_CEC_CPU_CLEAR, VC4_HDMI_CPU_CEC); - - return IRQ_WAKE_THREAD; + return ret; } static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) -- 2.28.0