From patchwork Fri Apr 26 16:02:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13645043 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35385C25B10 for ; Fri, 26 Apr 2024 16:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dE5DG3pbrIh9b9WJxKaNJKpEIBNi8HmuhwYCp3AY/fk=; b=ZtN1HmhQHBKNqc 6HWM7LSbIMyty/IZ0dLevMbhE0SxUb4ZnltqEkd7sg0O0lMxwU43P2ZfqqgEBRFRiHp4ID1oIuK0l zIyGOa2yhrpSWJ48YBppZn9aa3O1H3iqGXrInFc01SNuorC8MtSDyqCMwPx+Ss7ef3WKk70aIYJS5 a9+BXl9onIwbtKjPBFMmNbBe5M0dKe0CgMgimYcKqML+YEAM7C4ms5ByFAN0xyDhCcdodhB3cPabQ FJD91aRaMimZMpJMc/if7qVGJI/kvttkCkim8UMYwCgqba5WuJ18OfG4mwSX3iFEl3rcNV+3G7lvS E6UCiurPWrb9cYueMFSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0O2p-0000000DAp2-0k8R; Fri, 26 Apr 2024 16:03:27 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0O2j-0000000DAlb-2P4g for linux-amlogic@lists.infradead.org; Fri, 26 Apr 2024 16:03:25 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2d8a24f8a3cso27937971fa.1 for ; Fri, 26 Apr 2024 09:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714147398; x=1714752198; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LlYVJCYtRxxPVBcJn9HswhGBQFKRvWfDNGI/lisBMlg=; b=MT03rbXCFV3DIBIXWpHjCNqWeLJo4o+zkP1w+KK7y5SWio78rRgBYPjgH8vofNdVxh LbpTX5NSHO/HeMdJ0nP7gzUGcjG3o0dTY5iufJ6XIRhWnMznH9BPPJ7n+de+XEom3s0J 4z+2MegklIq22pCEEPqZtJpTVYJMqgbRznkLQ0+5vNqqYUXv5NujTreYM7WvgzkHUazL JYdr2V+MNMDUQg4UrCaaTohjQy0Bz4/hFMajevRlPadeZscv1CdgV7tvQls4gVAkcpbd O/pWYoDK9SiyxD0h5CbzEh1utfz3/D1bk+c1ULrTFufHntl9Vy9cd13NV2atbpLbAwss /eyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714147398; x=1714752198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LlYVJCYtRxxPVBcJn9HswhGBQFKRvWfDNGI/lisBMlg=; b=b4gscGWmvtF+tYfgcEU68rD5PpSlBVkNAPAYJiu3znXWn0Fsv3XrBDPbpgUpl9wgDF zule8ijl75+keV6yKPPLUoUZwhdUAoUJtR7sZk2LZQctPFJjGR5BP1+EEW1QGr6UWfZU PtoSIFcI/MCAmesd+NPBbW5oUVC6qIJeYQ6GaYhqznH9dIPXTFlDqzUOR70mrFdbv/Gk afcfZEZPa24rGR6bektZB0YQkSBa8B4ofsAX0BXIdaAtvuLf8nZsqC/Aebf+i6+kAu2c TbgAGAMmKwA6g9a0SzmQ6shjTkQwZDEe/DcsCUdursyGqJemuH9zj7qChfBuwFozzuf7 VoVA== X-Forwarded-Encrypted: i=1; AJvYcCWCAiNy64AnDzBqsrNj/ThMjdcKAGxDf4Ml4bn6RFC2vwwurowAXT43q+rmDVTHMLNPK0YkwpoarHvC1LvsygR9nyT0Jh7QWz53kzA64JyVWO8= X-Gm-Message-State: AOJu0YyyKvwkaK33xc3g5+ckkDQjoDrWiaJ/jbf1Kybx1at2TodPHugB CfPH4kk0E+YZ5694SqM2/4linPAeusg83xdG6Bo380pAN7ojbV5xzPEYP341FLmzqyA7TeTsUFH N X-Google-Smtp-Source: AGHT+IFW14tBfWL7cXos/nSxllpRy5uvA9d7tTy4bPugq4GLaF2Jd9gqDVK0xzBYq2SjTQFT1PuVCA== X-Received: by 2002:a05:651c:1a26:b0:2df:7009:63e3 with SMTP id by38-20020a05651c1a2600b002df700963e3mr1496141ljb.29.1714147398483; Fri, 26 Apr 2024 09:03:18 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1926:f73e:8b99:1c0a]) by smtp.googlemail.com with ESMTPSA id p14-20020a05600c1d8e00b0041bab13cd74sm1271408wms.17.2024.04.26.09.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 09:03:18 -0700 (PDT) From: Jerome Brunet To: Neil Armstrong , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Jerome Brunet , Kevin Hilman , Martin Blumenstingl , dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] drm/meson: dw-hdmi: power up phy on device init Date: Fri, 26 Apr 2024 18:02:53 +0200 Message-ID: <20240426160256.3089978-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426160256.3089978-1-jbrunet@baylibre.com> References: <20240426160256.3089978-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240426_090321_642592_568C35EB X-CRM114-Status: GOOD ( 14.66 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org The phy is not in a useful state right after init. It will become useful, including for auxiliary function such as CEC or ARC, after the first mode is set. This is a problem on systems where the display is using another interface like DSI or CVBS. This change refactor the init and mode change callback to power up the PHY on init and leave only what is necessary for mode changes in the related function. This is enough to fix CEC operation when HDMI display is not enabled. Fixes: 3f68be7d8e96 ("drm/meson: Add support for HDMI encoder and DW-HDMI bridge + PHY") Signed-off-by: Jerome Brunet Reviewed-by: Neil Armstrong --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 51 +++++++++------------------ 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 5a9538bc0e26..a83d93078537 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -384,26 +384,6 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, dw_hdmi_bus_fmt_is_420(hdmi)) mode_is_420 = true; - /* Enable clocks */ - regmap_update_bits(priv->hhi, HHI_HDMI_CLK_CNTL, 0xffff, 0x100); - - /* Bring HDMITX MEM output of power down */ - regmap_update_bits(priv->hhi, HHI_MEM_PD_REG0, 0xff << 8, 0); - - /* Bring out of reset */ - dw_hdmi->data->top_write(dw_hdmi, HDMITX_TOP_SW_RESET, 0); - - /* Enable internal pixclk, tmds_clk, spdif_clk, i2s_clk, cecclk */ - dw_hdmi_top_write_bits(dw_hdmi, HDMITX_TOP_CLK_CNTL, - 0x3, 0x3); - - /* Enable cec_clk and hdcp22_tmdsclk_en */ - dw_hdmi_top_write_bits(dw_hdmi, HDMITX_TOP_CLK_CNTL, - 0x3 << 4, 0x3 << 4); - - /* Enable normal output to PHY */ - dw_hdmi->data->top_write(dw_hdmi, HDMITX_TOP_BIST_CNTL, BIT(12)); - /* TMDS pattern setup */ if (mode->clock > 340000 && !mode_is_420) { dw_hdmi->data->top_write(dw_hdmi, HDMITX_TOP_TMDS_CLK_PTTN_01, @@ -425,20 +405,6 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, /* Setup PHY parameters */ meson_hdmi_phy_setup_mode(dw_hdmi, mode, mode_is_420); - /* Setup PHY */ - regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, - 0xffff << 16, 0x0390 << 16); - - /* BIT_INVERT */ - if (dw_hdmi_is_compatible(dw_hdmi, "amlogic,meson-gxl-dw-hdmi") || - dw_hdmi_is_compatible(dw_hdmi, "amlogic,meson-gxm-dw-hdmi") || - dw_hdmi_is_compatible(dw_hdmi, "amlogic,meson-g12a-dw-hdmi")) - regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, - BIT(17), 0); - else - regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, - BIT(17), BIT(17)); - /* Disable clock, fifo, fifo_wr */ regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, 0xf, 0); @@ -656,6 +622,23 @@ static void meson_dw_hdmi_init(struct meson_dw_hdmi *meson_dw_hdmi) meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_CLK_CNTL, 0xff); + /* Enable normal output to PHY */ + meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_BIST_CNTL, BIT(12)); + + /* Setup PHY */ + regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, + 0xffff << 16, 0x0390 << 16); + + /* BIT_INVERT */ + if (dw_hdmi_is_compatible(meson_dw_hdmi, "amlogic,meson-gxl-dw-hdmi") || + dw_hdmi_is_compatible(meson_dw_hdmi, "amlogic,meson-gxm-dw-hdmi") || + dw_hdmi_is_compatible(meson_dw_hdmi, "amlogic,meson-g12a-dw-hdmi")) + regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, + BIT(17), 0); + else + regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, + BIT(17), BIT(17)); + /* Enable HDMI-TX Interrupt */ meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_INTR_STAT_CLR, HDMITX_TOP_INTR_CORE);