Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp550267lqp; Wed, 22 May 2024 12:00:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3D05hN/srQLxC5IkFhfQUVOvF0M29g7DaQLs8vMeVjj4cumQmjGHwE/iD93cHW+VRnsm+wNazzO3bRI1sah6odqMI6cyBTiicOHswyg== X-Google-Smtp-Source: AGHT+IES8u69d6DvmiWUDIbyevfIS1X+s4WajPUlhRcFeF55T1jPB1KvNPl1DKU8OMMJDtl6Lbkw X-Received: by 2002:a05:6214:398e:b0:6aa:2697:274a with SMTP id 6a1803df08f44-6ab7f19aa4dmr34131236d6.0.1716404418364; Wed, 22 May 2024 12:00:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716404418; cv=pass; d=google.com; s=arc-20160816; b=Oabs4VaZPvVXcof9H4acg+r/QgURzzhiVif31b4VlFOtKc9fOTUjDW6KrxbH1paCDj CVEG/X2xSNnONB2pb14U4K+MCKD+vQ4WEY0WooW700tXVd0+KIwv5hdB6JuZ9G2sH0nV 477GO5g/IXBnxqqM2KyakYinurfUCrL/OsWfKlU5D5kI3zIVqoBOikWQqPJrOv2pxKuQ ycQ1cuFIfBKQsSktogfI5ZVbfL6P57GCHlXfJTZWDP9aMGcINV1YTRtaf1ZkK0O5sdqb 020l/06UoM+VR7mnyUD+ajfXvnaxQj1jw6TimW1a52ztaKsl2oPhUJ6tUo3Bn9/htL/8 e+7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Me1I6NPaFfmd7z+97q5kpTjSiVS/t3tMj84c4gfIvZA=; fh=/tZG21HuMcLywh7O3XGuiVOox9dhfdDvu1Fi57z6UFg=; b=dqD4BlnNZCirQp88hbzRtCcvjr7/gKJlocb51QTZmBp1cmVkPd/byZ6H70YEURneUA IY0OiK57kdQX+RdJxA+0WJ19rOoPX26baJZA4imWnzYmZlaP05rJyAMon9epUXOsJuGj Ws9NxpQwbix3OpjSRR3uiiSjF2s0zsOl2dK8hnSRUqxU5V0ITYiLvuRKNr3SCa2sv9Dl XKgH7ICQroIHeoX0sVKcHPW0u700wpBPSiCTU/7hJd+3l5pGZJOXKImaeyy00gde7kkv 7u80Kl2FvKmSbO2L5I3t/i+wP/8eWrzQISiqSV66UP9og3UEPhy1glYnUBqEHknjUZfa OJTw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=08XQe887; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-186635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f29d653si307321206d6.201.2024.05.22.12.00.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 12:00:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=08XQe887; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-186635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AD1B51C21B07 for ; Wed, 22 May 2024 19:00:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FA4E146A7D; Wed, 22 May 2024 19:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="08XQe887" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3151146A6A; Wed, 22 May 2024 19:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716404403; cv=none; b=G6cMScSKl3tVAkhVnag/SccdLkxmvYOmhWZCp5UVG6W21h3MesPw0JXJ3DvCC1qqhLJEfNIrFodk+Gw6ypQvpIDyMAw2UWLN6W6N0jiDquQlsQ60Gtq3Mb9SH4BxsHkNg6bD+WJ5Zyb1Fuo3gmlAaZT6Rsfca/kxrYfaefPtjMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716404403; c=relaxed/simple; bh=PVF+wmm/VCwQDTYpdenLM3gXX3oTTIiq5Q5qfjbuvLE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s3WrVgawytSG/apY6tQLHbKixvOYy4H1VbXpG+/WoV0S3jvJtWCkeLHQUzenFjxD+q+4KKWwG7aDL47JNnBmnOtZTFLnh1ER3QClyMgDkaAe8aSuw/jSa7aiPSRBSBEy9S9xwoLCiEdzLac58NJW8lP0MVpSznUl5Ng88g+lKeY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=08XQe887; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1716404400; bh=PVF+wmm/VCwQDTYpdenLM3gXX3oTTIiq5Q5qfjbuvLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=08XQe887W1a3THcyloUj9bHJ9IdB4JXxZhcaOun91U4AUljYMREpO5d+Wky9QpOmN epFZT7kJTR7z18QGZ2CouCWvGCO9u/QbMjuT1CrHNTfCEAu3fv2K8g8KFpknPFqvbc KJvXpL3MTUMgpskmorA9bY7aIKkbEUkeN7iR94CGMrA1xGWP+ggURlhE1OhX/l6YwX Z+dulPucGSU24QeJN55sMqu/Dt6+fMfsdy7KJsGoslcc4CQvrvlOXSAfB+1rt+lf7q WimPioxOoZ1fyLn8aAXs4MEg/sOfQ/o/RbQr1XtQiuVo29Hcuq5mgp3Bbz+BAtFAMn ANtpc5obaYsTQ== Received: from arisu.mtl.collabora.ca (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 37792378218D; Wed, 22 May 2024 18:59:57 +0000 (UTC) From: Detlev Casanova To: linux-kernel@vger.kernel.org Cc: Sandy Huang , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Andy Yan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Sebastian Reichel , Dragan Simic , Chris Morgan , Diederik de Haas , Boris Brezillon , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, Detlev Casanova Subject: [PATCH v2 1/3] vop2: Add clock resets support Date: Wed, 22 May 2024 14:57:48 -0400 Message-ID: <20240522185924.461742-2-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240522185924.461742-1-detlev.casanova@collabora.com> References: <20240522185924.461742-1-detlev.casanova@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit At the end of initialization, each VP clock needs to be reset before they can be used. Failing to do so can put the VOP in an undefined state where the generated HDMI signal is either lost or not matching the selected mode. Signed-off-by: Detlev Casanova --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index fdd768bbd487c..e81a67161d29a 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -157,6 +158,7 @@ struct vop2_win { struct vop2_video_port { struct drm_crtc crtc; struct vop2 *vop2; + struct reset_control *dclk_rst; struct clk *dclk; unsigned int id; const struct vop2_video_port_data *data; @@ -1915,6 +1917,26 @@ static int us_to_vertical_line(struct drm_display_mode *mode, int us) return us * mode->clock / mode->htotal / 1000; } +static int vop2_clk_reset(struct vop2_video_port *vp) +{ + struct reset_control *rstc = vp->dclk_rst; + struct vop2 *vop2 = vp->vop2; + int ret; + + if (!rstc) + return 0; + + ret = reset_control_assert(rstc); + if (ret < 0) + drm_warn(vop2->drm, "failed to assert reset\n"); + udelay(10); + ret = reset_control_deassert(rstc); + if (ret < 0) + drm_warn(vop2->drm, "failed to deassert reset\n"); + + return ret; +} + static void vop2_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_state *state) { @@ -2055,6 +2077,8 @@ static void vop2_crtc_atomic_enable(struct drm_crtc *crtc, vop2_vp_write(vp, RK3568_VP_DSP_CTRL, dsp_ctrl); + vop2_clk_reset(vp); + drm_crtc_vblank_on(crtc); vop2_unlock(vop2); @@ -2706,6 +2730,12 @@ static int vop2_create_crtcs(struct vop2 *vop2) vp->data = vp_data; snprintf(dclk_name, sizeof(dclk_name), "dclk_vp%d", vp->id); + vp->dclk_rst = devm_reset_control_get_optional(vop2->dev, dclk_name); + if (IS_ERR(vp->dclk_rst)) { + drm_err(vop2->drm, "failed to get %s reset\n", dclk_name); + return PTR_ERR(vp->dclk_rst); + } + vp->dclk = devm_clk_get(vop2->dev, dclk_name); if (IS_ERR(vp->dclk)) { drm_err(vop2->drm, "failed to get %s\n", dclk_name); -- 2.44.1