Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp951595ybm; Wed, 27 May 2020 12:01:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhq6ULVTq1iWIYOJfWj5hmNi9BrX3ZUPPhaMFRZdC3h6XVUPm09aHbAJlUH9O60L7iVvav X-Received: by 2002:a50:d1d3:: with SMTP id i19mr24718829edg.35.1590606084718; Wed, 27 May 2020 12:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590606084; cv=none; d=google.com; s=arc-20160816; b=nxUvFHjBRQLj7cQHNh8O+9eLaF/iUFZaTc496tg3yN3sGKR/V+oX6BcCdfPp3Jk59y 6m/SlYwM3kcMI+SNjFjWuoABwe+gDp7upJvpFhC63Xq9EEbdscFlOFRRJKoGGmEA0hUq GLoa/QpBzGOU0tlqH1/91Tbsb1IqkHLzfu5te2mcQGm8WwNEyJqQgPg5OLJ9k+J5itKA JBqHZn5jFquxiaC+xSQIa11xoDKxxsFROqTHzJ3+Azh+J6gnAFO24aAeuUBk5UtEF9m0 t4PPBQf/iBrL+wcgRCorJOxnSic0yP8usuhPcTeQoZDZz2s1D9HGpesO6KfezBGFHLAN xGqA== 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=Qt9/P4yukHV2BTUxxyxl9vY352xX2ptPfPzVLjzzRFg=; b=cbz0rT3A6jSII+t68GHFNfVtKiYccSXwmFKamsr575B67U9zdjPvKD2BXX1ToK/sCi B36qugfxWkndI5GjwkLzNAtNxUk+PRhwm2MygNLRsf9QeYpb6oUFDoagPcuTxwbTfOwr PjdrvNFHAyqqaHzUoSC0nZQ2fC0Wtc3Lnq1lOhXlPKjXEhCZR9gRw6ytKJNIwp7gEesy gjN7554ffT0LcqmYeY7lXqvCaK84aF2LBskVYiKU8nvTpvUudEwCNrT1vVx3XTKORSMa 3ygvDZ91WySq/g1P5cMeEgoLj3WbdevGW4gaGAp/5CiikdpVB4FR6u/KWNZ6QbjSBaUJ IqwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=sVRlM84x; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="J2/RQ2kR"; 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 a26si2254388edr.356.2020.05.27.12.01.01; Wed, 27 May 2020 12:01:24 -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=fm2 header.b=sVRlM84x; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="J2/RQ2kR"; 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 S2390427AbgE0PwQ (ORCPT + 98 others); Wed, 27 May 2020 11:52:16 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:53493 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730592AbgE0Pv2 (ORCPT ); Wed, 27 May 2020 11:51:28 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id D3F575814F9; Wed, 27 May 2020 11:51:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 27 May 2020 11:51:26 -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=fm2; bh=Qt9/P4yukHV2B TUxxyxl9vY352xX2ptPfPzVLjzzRFg=; b=sVRlM84xe3TyV0NPrwgJBwH7ZsZAM MklsRzKl5y8mqAaxIjVJfMCCzXWCLoLw1lOiDVR38y92KDT6erd1dxqbpFAuOcYs jD/IUd/4Idc5i2IxJbNEGSjWbrqtEMpAiPiXE39KOK3SbaOcOI/WcuFxdRmXAL1A iTv55a9sIv3Vsi+GDw6zEZ9nB+WeDuDKIkb+MsiERKL81YitJRKiW4RQHRsg2Rzz CECGngwsNIZSfIc87ba/VPw43Ga26aSEMfYJVWUJYXtbnYvZUfE+IYvAXhJPJmWu Yqk9wEFkhriC5aehnjBkZQFZYwTfkq7ajlWbKo9IwNLADp4dPgHTpEhJw== 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= fm2; bh=Qt9/P4yukHV2BTUxxyxl9vY352xX2ptPfPzVLjzzRFg=; b=J2/RQ2kR v98ruPKOf6pL1rocIL6Qq8IONCT+Kdz5cO+nRBnjzH2xmuhp9on7iQg89CSLJb53 vPIkM01yg1d/uBJ9o0dvthq92FCAmYpWzknhKor+0T+wwK2kdkhZivE9mpj0FjaX sussLiepjHxHgLfmKlHqMWwXQuPH0RrUvwmCsGAvLVNVj9WWxwGkI0aE/QzyqduG qW2KRRQWeLoomrhsQFfi0Z8OCtuQ49+hXX2LsgzrwDS9TYmolUqVCxsO9EYoc6ze nQspnsjEVD1w0mcEb8RZbQw1R8Yc/hFKryjuy/k7oT+CkItQl9K8dKS5bIpiMaMy 0p6+2Oqu8Wklkg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddvgedgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepheelne 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 70284328005E; Wed, 27 May 2020 11:51:26 -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 v3 082/105] drm/vc4: hdmi: Add PHY init and disable function Date: Wed, 27 May 2020 17:48:52 +0200 Message-Id: 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 dceff505c840..3d5e35aa96ff 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); @@ -1414,6 +1412,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 93695674c2d3..39ae5273f36b 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