Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2761653lqo; Tue, 14 May 2024 08:24:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCULqXZWuQgmpofMJYNGMcmUR695akZuv//xbrRbGri1qFQjKtpaJTWBUyJvWglqbkB0fRm73/tXk0lz0Q2GmfEk54Af7jggxvRCJXmwvg== X-Google-Smtp-Source: AGHT+IGmhqRujBxU8qBUqLftUTOGzb+U93/yhDD4akDHI+zEs+ekc3puTSh9vnOjlQI+tslAlxme X-Received: by 2002:a50:9f88:0:b0:572:a7fb:b6ad with SMTP id 4fb4d7f45d1cf-5734d590353mr9767391a12.5.1715700274092; Tue, 14 May 2024 08:24:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715700274; cv=pass; d=google.com; s=arc-20160816; b=fYbkBIZvgON2Fxh5v5EK87UGnxQ8X5uKuSHkXlegzplOqSjo6SzQxNJf/Oxv9sENmn bVQd87Dep3E5nrUbv1ipwh5roVNBS5ne/zL8/p+1Kl9W5v5P/Q1zMYXOR4JVSMwiDko7 HuGtBmC8lPPaCvjL8DR1a/qVyCbPkGmQa8lw7dweMXtAjzpPlZPqUigtdmxmEa+i2UOH 4BRks5DqqF1MB4VbfQ0EJ6HtKwVyA0nbcSfvvcaOpYRQjv5Eku1hdOaeE7R4Y+VFTOUY 9OhwlnJ32dQzGjlg5iPkrZatWUL8U4QjDDLB5Tt8j6geLz+0Fjv7XT+sD46hCyD8lT1k yEsg== 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=ZPbR18VkZPPbI6tEJCooGH46XEtTmYTiZFuZZP34D2Q=; fh=/tZG21HuMcLywh7O3XGuiVOox9dhfdDvu1Fi57z6UFg=; b=qon16SHf/XaFSPT3KgYtEHsCOR1CpTed2N1c/uShXkdVjxFQwAB07jF5AxGmVCpEGQ XalSYZreaeVhJMhAxbYfQBJ/nDwAM4L9u4jcwSbDoUw8iyTsVIgWZ3EPd9qzdSacv/eu nMQ/2GMdWUOJdscyjW3DpO3naG0eimRsAPDiXxc+z6kHNtrj9PDSyZIfkS3rPq3WEnEg 4JdAt1jVZ7cWX44Ec2h0GV9S67aVqx2Vnhj60faG6/pdyUVhV8USBe5vWoiF+RmX8RSy HaRznbPCgHnoU38xKZwpwv6yrBEIxVhUxS0N7pqXW9rcHpn9+Bq8JesezQCRnmGBk3Nu Wb+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="FTBoB/7u"; 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-178853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733beac2f7si6444956a12.30.2024.05.14.08.24.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 08:24:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="FTBoB/7u"; 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-178853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178853-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D182A1F22822 for ; Tue, 14 May 2024 15:24:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A71017F36C; Tue, 14 May 2024 15:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="FTBoB/7u" 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 41C0A17EBAE; Tue, 14 May 2024 15:24:15 +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=1715700257; cv=none; b=Y/jt9s85uASQJAkxHpQ53ZI8l3WBrYgXgAL62C5mUqetSOALR5TNvxQfdRoJ1KpFjIhT/0habCGxDH5x8CqGla1MvdooLhpHWyWiTOlCANWNdUqoE0hIJ54sOb4Zzo7RDvWVm+0h1WPMrCRNVj+5ToFoNxgPB39i3Hsg70WDCg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715700257; c=relaxed/simple; bh=PA/IrvxvIM1ep8+7B89JcUeTkpU1YjsSPqMoeUWmhXE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pRpdWqXxNFcsM1enGIywV2J8wo3t+dDbxWz2nrqm1tkB9Z7PR50KpMtxSnsJqNP6bEJRKZSBvrRQhxAohBnMBCtyHimd96x0LpPmqW/RpP7b8sOviS9d5d32ys/UicMZ0UzV8vHEZeHP+vp1cohxdZeP/mysqbj5YBGNk0YmQcM= 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=FTBoB/7u; 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=1715700254; bh=PA/IrvxvIM1ep8+7B89JcUeTkpU1YjsSPqMoeUWmhXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FTBoB/7uotXXUuwJ8K2YfoYtA/rDvdjmDaQQEPVWDdXWA202pbtg8J7SPXQoW3ufN UaQMlPxpioSSIfoX90k0nPA377XM0GYLVHL/atltBTMSY33pYN64CCHQQW2my9agS7 k/on0z/UGaaQs0akuOubpl1+KtZ0ciLAtOcDl+vC+Hyi4BtJpRN89jDlNUrO7rnnWK cv7xupPLy+51AxvvlgSE/2fR+O/+lO4g/0ed1R8e9SxfRo6db8xh+lYlmgiZ1dkIEb DhQ9mtc51bNAsvyVAR5SrC1jJpcitZuhfkPgAdQdHPBPYBZlL4v17cAt9ZzhixLReG S7lwSTHqRC0EA== Received: from arisu.hitronhub.home (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 ED28B3782191; Tue, 14 May 2024 15:24:10 +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 1/3] drm/rockchip: vop2: Add clock resets support Date: Tue, 14 May 2024 11:19:45 -0400 Message-ID: <20240514152328.21415-2-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240514152328.21415-1-detlev.casanova@collabora.com> References: <20240514152328.21415-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.43.2