Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp751755ybt; Wed, 8 Jul 2020 10:45:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyw+wE1n0DnTmH9ZGRFbvBwdMIDWAo5+/mHp5v71X9rWJRP6sKrF3hW6Aimec25g8CNUKn X-Received: by 2002:a17:906:160f:: with SMTP id m15mr46814583ejd.423.1594230316058; Wed, 08 Jul 2020 10:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594230316; cv=none; d=google.com; s=arc-20160816; b=vvEZKlDNA7M7/8kQdqcDj/n+34arqghKsWE/bJzbXwII7kDwXet/jEw7I0bBRuLae9 pJkbyGgZyjbBEvPOyjJNw8b+BN9aNaDcIbqxGq7Kt6eD/ROeqkSVqJK2nZjuza6MyUyW XjYUlOGLMUBaWErdNS97or5AE8rBPKbiTjYjpTsRBq1puez9Is1tRMWbly4D4nr1iQtF npD5GSPzMHAb0zC23taWM0/xEMcTVPjA/ceAUf4n4O25IV5Hv5qwBINQPRYel0V1hG7h w9sXomelNex3SxLJ4aa/Bb387WvGlaeegKLIQpGvfGc7PeCaUO8mIEdC38/qzfH7moBq dnSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=umYpp2PP7K8SFFzdrljzHhPSyXr1ifT9OKrxdCyKq/U=; b=M8HVJLvXmMpEyI0VzqukBs2QQ0N8AX5melhSWETuKN65OMv5DMa6I3wO/D94jgl4MX HFNcpyUr/j86lLuSjEewfypg2rbW1jpNtGu8DVoP1N96w7pgFAcpJTzaWCXanEFqxXmy 0FivkfGjsqa4y+nHxgo61kEkwBMZQNVldbw0p+36zBoiccDnrplcXTfVODShsIdDR7Va l+RBRmbC2h+pu+Y9CFbz+H+UQDFeNr3QAUm4c2/KR/RTedm/NbsCIiyn0qyIgEcipQCI 9LDmSWNnV/NAtzWcuGny8a0N9mjOGJFYbWKaEG7KXqkJp9wTtF2TIStAG3y1LbEo10QX z4mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=DGlfhGn8; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=WLUuGt6A; 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 g10si329285ejf.54.2020.07.08.10.44.53; Wed, 08 Jul 2020 10:45:16 -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=DGlfhGn8; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=WLUuGt6A; 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 S1727870AbgGHRny (ORCPT + 99 others); Wed, 8 Jul 2020 13:43:54 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:44105 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727831AbgGHRnt (ORCPT ); Wed, 8 Jul 2020 13:43:49 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id F332D333; Wed, 8 Jul 2020 13:43:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 08 Jul 2020 13:43:48 -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=umYpp2PP7K8SF FzdrljzHhPSyXr1ifT9OKrxdCyKq/U=; b=DGlfhGn8pQwbB8umaea3G43riY3uP exTdmr2XRE5ON35XhNn4fnOzxyWl1/U0RDAiH9eadfmg0lBa89PaBKsbueUoYaZk 48rZvn4i9P8Pc1rMDr+WAWVS59AcL4U6ZYezQjJEuTTX9C/WsIQwFW83A48j8App 6r3mrffg3YFL7yPH+OnPqDB3l5Eh2fAcJ5qBrQhrDUJJuSh/8yoSTae9sgGr8edb 2k6p+g+SYyzC6xGLWYEI6w+wRMJLHMAfMEn8ZNEZsSZ7WvCAUR83V3yiljxswQq9 sK/790wXxcGQPfETib1uXcz0CxMPMolzLww/wlErFXQo2SWAl2//RIyBw== 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=umYpp2PP7K8SFFzdrljzHhPSyXr1ifT9OKrxdCyKq/U=; b=WLUuGt6A N27dGkC78t0XehhWgZoYKTPflqmqgJvRUp0e8zEGSHoWZgt0/RTaYTWuAdIhq0If bLrfxcplc9+aWLkSsQXi8tJB02YGXwTpN1ZT4qIW8EyD+rhMHTg1pkhQRm6xQ/BT BPImEY9R/3yikAgOCb5irAnuTbAK4GwE+JRGoGCJ0WHLs/ztHQDq0Di3B+9r+d0c Nq1RHBVtIBosg4sOfWVUX8BQxBW64vwFCHfVGb5hZOaoJSCx7Dtx+C00bibDyJ3S L5lDUQzIZLLJ8dQ3843JtrlIHfVyH3t27PE+Jn/LrIPK9RUh/T5w93R4wVEvkc94 xBm3QIuV6t7uBA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudejgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepgeeine curfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh 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 399A8306005F; Wed, 8 Jul 2020 13:43:47 -0400 (EDT) From: Maxime Ripard To: Nicolas Saenz Julienne , Eric Anholt Cc: dri-devel@lists.freedesktop.org, linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Stevenson , Tim Gover , Phil Elwell , Maxime Ripard Subject: [PATCH v4 53/78] drm/vc4: hdmi: Add PHY init and disable function Date: Wed, 8 Jul 2020 19:42:01 +0200 Message-Id: <9ac309938e18a55c1c48d3520fe51a61f3c09b1f.1594230107.git-series.maxime@cerno.tech> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The HDMI PHY in the BCM2711 HDMI controller is significantly more complicated to setup than in the older BCM283x SoCs. Let's add hooks to enable and disable the PHY. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/Makefile | 1 + drivers/gpu/drm/vc4/vc4_hdmi.c | 14 +++++++------- drivers/gpu/drm/vc4/vc4_hdmi.h | 13 +++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi_phy.c | 25 +++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/drm/vc4/vc4_hdmi_phy.c diff --git a/drivers/gpu/drm/vc4/Makefile b/drivers/gpu/drm/vc4/Makefile index b303703bc7f3..d0163e18e9ca 100644 --- a/drivers/gpu/drm/vc4/Makefile +++ b/drivers/gpu/drm/vc4/Makefile @@ -12,6 +12,7 @@ vc4-y := \ vc4_kms.o \ vc4_gem.o \ vc4_hdmi.o \ + vc4_hdmi_phy.o \ vc4_vec.o \ vc4_hvs.o \ vc4_irq.o \ diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 80bc3dd9d4a8..068041145d1c 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -321,7 +321,9 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder) HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0); - HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0xf << 16); + if (vc4_hdmi->variant->phy_disable) + vc4_hdmi->variant->phy_disable(vc4_hdmi); + HDMI_WRITE(HDMI_VID_CTL, HDMI_READ(HDMI_VID_CTL) & ~VC4_HD_VID_CTL_ENABLE); @@ -381,12 +383,8 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) if (vc4_hdmi->variant->reset) vc4_hdmi->variant->reset(vc4_hdmi); - /* PHY should be in reset, like - * vc4_hdmi_encoder_disable() does. - */ - HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0xf << 16); - - HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0); + if (vc4_hdmi->variant->phy_init) + vc4_hdmi->variant->phy_init(vc4_hdmi, mode); if (debug_dump_regs) { struct drm_printer p = drm_info_printer(&vc4_hdmi->pdev->dev); @@ -1433,6 +1431,8 @@ static const struct vc4_hdmi_variant bcm2835_variant = { .init_resources = vc4_hdmi_init_resources, .reset = vc4_hdmi_reset, + .phy_init = vc4_hdmi_phy_init, + .phy_disable = vc4_hdmi_phy_disable, }; static const struct of_device_id vc4_hdmi_dt_match[] = { diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index 17a30589f39c..32c80161c786 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -21,6 +21,8 @@ to_vc4_hdmi_encoder(struct drm_encoder *encoder) return container_of(encoder, struct vc4_hdmi_encoder, base.base); } +struct drm_display_mode; + struct vc4_hdmi; struct vc4_hdmi_register; @@ -38,6 +40,13 @@ struct vc4_hdmi_variant { /* Callback to reset the HDMI block */ void (*reset)(struct vc4_hdmi *vc4_hdmi); + + /* Callback to initialize the PHY according to the mode */ + void (*phy_init)(struct vc4_hdmi *vc4_hdmi, + struct drm_display_mode *mode); + + /* Callback to disable the PHY */ + void (*phy_disable)(struct vc4_hdmi *vc4_hdmi); }; /* HDMI audio information */ @@ -95,4 +104,8 @@ encoder_to_vc4_hdmi(struct drm_encoder *encoder) return container_of(_encoder, struct vc4_hdmi, encoder); } +void vc4_hdmi_phy_init(struct vc4_hdmi *vc4_hdmi, + struct drm_display_mode *mode); +void vc4_hdmi_phy_disable(struct vc4_hdmi *vc4_hdmi); + #endif /* _VC4_HDMI_H_ */ diff --git a/drivers/gpu/drm/vc4/vc4_hdmi_phy.c b/drivers/gpu/drm/vc4/vc4_hdmi_phy.c new file mode 100644 index 000000000000..5a1746877bb5 --- /dev/null +++ b/drivers/gpu/drm/vc4/vc4_hdmi_phy.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2015 Broadcom + * Copyright (c) 2014 The Linux Foundation. All rights reserved. + * Copyright (C) 2013 Red Hat + * Author: Rob Clark + */ + +#include "vc4_hdmi.h" +#include "vc4_hdmi_regs.h" + +void vc4_hdmi_phy_init(struct vc4_hdmi *vc4_hdmi, struct drm_display_mode *mode) +{ + /* PHY should be in reset, like + * vc4_hdmi_encoder_disable() does. + */ + + HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0xf << 16); + HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0); +} + +void vc4_hdmi_phy_disable(struct vc4_hdmi *vc4_hdmi) +{ + HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0xf << 16); +} -- git-series 0.9.1