From nobody Mon Nov 25 17:43:29 2024 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22490224DA8 for ; Fri, 25 Oct 2024 17:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729876582; cv=none; b=NrqaIx6uKbjyackaOwvImNR1EWtxhCe/WZVAuXA2v+b6XwXq/QmbXU9WvOaCEUGVtCFufZixh/NrG6gQBo8VYbc4tkkIl14Z0sKAY1eE4+gm6BGAY4NiVr01Fo53rZGQNoYyLghLnW0aIhES+fb4jZXuAjxIIdiUPVyZ0ZP2+PY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729876582; c=relaxed/simple; bh=WV/UFQyvWXojwAqHvOtHxgMXrfRl7lw3BEm8g+qz5Yo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tNCjxiXnFJ+SFkE6uqyW3ibvKZAt2bBL4c/k8Bi6Jz+FdTcin4me713BtxAnUgazxC42jjL4ntXx+ni43sV3ikxsdX9vEeluxdZMvdi0LmieVYUO8QH3wrzmCNYrP9/iMR/c+DbFAnV0lhNCI8V6bfO6ch+w0/FLUNFzUaaOAz8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=f9CD0WTz; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="f9CD0WTz" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-37d58377339so1728738f8f.1 for ; Fri, 25 Oct 2024 10:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1729876575; x=1730481375; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xZSl/F4a59d6cGzaQ8UBGb7tAkWNLG3z9Ozwy3jDhoY=; b=f9CD0WTzvGO49lrQw333IymYW+nanWfJp+vvAhUi9bwAfgrFeG1nrBUEkak7l1HBK4 MGojIt1LP2vIGUR2E1UwIYCbHLgKXxH/XZSsmdMIC3ITeuIDMie6m++59oac7Fy9km0L 1y3wTGGvwja9cdfmp+ORo2dMIcARj0uAmHO0zlI/6O6TisopvwEOs6GcVJijmybHa+9T bl4Y4u+zW/LQrurvUZcrMgHW14TAZRacfQ9tRsvi4GDBmmTdXCqvQNO5VzSy+WZ5uWz8 k2PeiWktYT4PlFBIcgcm27kB8e1aNjn1gykRFhVlKl3I+5BMV0E4QRCein+xtlCvz1gf OCvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729876575; x=1730481375; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xZSl/F4a59d6cGzaQ8UBGb7tAkWNLG3z9Ozwy3jDhoY=; b=pRq67gmnsA7sTxn/t7LTqz9hAH6fdg+ZHouKLaRG2bK2+OmEKfVqykrmLHBdwhG1lZ Ifbhj+aSYTElCbFh6BYVMdOoJCWC4u1sapOlrMBBue+59QfNPJh8g/aSljmSDhqEeNUU oqaoUbWoFVl4/MIpsT7fyQi5ApQ3gX6q2VFiGKpcMIzk1Y5ZOMkM/XzZvxhCCGDZ0UdM SX3XsmqhUjO4r6fda6f+tSOaUIQhRn5R2+FK4z4TH+YBWkFq7qlVziI0wI4DwKe2chqs c1e5+rr1eAEKNCLyh5Rtp+wIFYrXmHv0sQzmm62QdHzVQ7q7nHIPwTNzOxZQkqga6so3 luqA== X-Forwarded-Encrypted: i=1; AJvYcCXtOBgL74K40tahj9CssLX4C4anYEJkFTEMyWz6I3GYa6SOUEuDZft/8LfWgAl+wYdpcKDkiIo4DJ5+un4=@vger.kernel.org X-Gm-Message-State: AOJu0YzwDhadl2KkrLZChYpMwzMN7xEN6nl3aEsaGPLN6H5+UDH5CEGT /hvqG+2EmaJfXgqTj+BJaiYgUZzCAsdcR0GlImnrQAdNzohWyTqpkux3Z3EBnjk= X-Google-Smtp-Source: AGHT+IGYCJwSrz9ld715UfDoH5XKNaydjNgYU5P9irKdws9FIn39XqxjXFv+TI0I/O8NtYhIy9aKqg== X-Received: by 2002:adf:f850:0:b0:37e:d2b8:883a with SMTP id ffacd0b85a97d-380611409c4mr151148f8f.12.1729876574029; Fri, 25 Oct 2024 10:16:14 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-38058b91f50sm2013649f8f.94.2024.10.25.10.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 10:16:13 -0700 (PDT) From: Dave Stevenson Date: Fri, 25 Oct 2024 18:15:44 +0100 Subject: [PATCH v2 13/36] drm/vc4: txp: Introduce structure to deal with revision differences Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241025-drm-vc4-2712-support-v2-13-35efa83c8fc0@raspberrypi.com> References: <20241025-drm-vc4-2712-support-v2-0-35efa83c8fc0@raspberrypi.com> In-Reply-To: <20241025-drm-vc4-2712-support-v2-0-35efa83c8fc0@raspberrypi.com> To: Maxime Ripard , =?utf-8?q?Ma=C3=ADra_Canal?= , Raspberry Pi Kernel Maintenance , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Michael Turquette , Stephen Boyd , Javier Martinez Canillas , Catalin Marinas , Will Deacon Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 From: Maxime Ripard The BCM2712 will have several TXP with small differences. Let's add a structure tied to the compatible to deal with those differences. Signed-off-by: Maxime Ripard Signed-off-by: Dave Stevenson --- drivers/gpu/drm/vc4/tests/vc4_mock.c | 4 ++-- drivers/gpu/drm/vc4/vc4_drv.h | 6 +++++- drivers/gpu/drm/vc4/vc4_txp.c | 23 ++++++++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock.c b/drivers/gpu/drm/vc4/tes= ts/vc4_mock.c index 6527fb1db71e..c7b91c87f1bc 100644 --- a/drivers/gpu/drm/vc4/tests/vc4_mock.c +++ b/drivers/gpu/drm/vc4/tests/vc4_mock.c @@ -51,7 +51,7 @@ struct vc4_mock_desc { =20 static const struct vc4_mock_desc vc4_mock =3D VC4_MOCK_DESC( - VC4_MOCK_CRTC_DESC(&vc4_txp_crtc_data, + VC4_MOCK_CRTC_DESC(&vc4_txp_data.base, VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_TXP, DRM_MODE_ENCODER_VIRTUAL, DRM_MODE_CONNECTOR_WRITEBACK)), @@ -77,7 +77,7 @@ static const struct vc4_mock_desc vc4_mock =3D =20 static const struct vc4_mock_desc vc5_mock =3D VC4_MOCK_DESC( - VC4_MOCK_CRTC_DESC(&vc4_txp_crtc_data, + VC4_MOCK_CRTC_DESC(&vc4_txp_data.base, VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_TXP, DRM_MODE_ENCODER_VIRTUAL, DRM_MODE_CONNECTOR_WRITEBACK)), diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index a68cea921c11..1ed1fb5aa7e8 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -536,7 +536,11 @@ struct vc4_crtc_data { int hvs_output; }; =20 -extern const struct vc4_crtc_data vc4_txp_crtc_data; +struct vc4_txp_data { + struct vc4_crtc_data base; +}; + +extern const struct vc4_txp_data vc4_txp_data; =20 struct vc4_pv_data { struct vc4_crtc_data base; diff --git a/drivers/gpu/drm/vc4/vc4_txp.c b/drivers/gpu/drm/vc4/vc4_txp.c index ffe1f7d1b911..dcb1b3fd37de 100644 --- a/drivers/gpu/drm/vc4/vc4_txp.c +++ b/drivers/gpu/drm/vc4/vc4_txp.c @@ -159,6 +159,7 @@ =20 struct vc4_txp { struct vc4_crtc base; + const struct vc4_txp_data *data; =20 struct platform_device *pdev; =20 @@ -484,17 +485,20 @@ static irqreturn_t vc4_txp_interrupt(int irq, void *d= ata) return IRQ_HANDLED; } =20 -const struct vc4_crtc_data vc4_txp_crtc_data =3D { - .name =3D "txp", - .debugfs_name =3D "txp_regs", - .hvs_available_channels =3D BIT(2), - .hvs_output =3D 2, +const struct vc4_txp_data vc4_txp_data =3D { + .base =3D { + .name =3D "txp", + .debugfs_name =3D "txp_regs", + .hvs_available_channels =3D BIT(2), + .hvs_output =3D 2, + }, }; =20 static int vc4_txp_bind(struct device *dev, struct device *master, void *d= ata) { struct platform_device *pdev =3D to_platform_device(dev); struct drm_device *drm =3D dev_get_drvdata(master); + const struct vc4_txp_data *txp_data; struct vc4_encoder *vc4_encoder; struct drm_encoder *encoder; struct vc4_crtc *vc4_crtc; @@ -509,6 +513,11 @@ static int vc4_txp_bind(struct device *dev, struct dev= ice *master, void *data) if (!txp) return -ENOMEM; =20 + txp_data =3D of_device_get_match_data(dev); + if (!txp_data) + return -ENODEV; + + txp->data =3D txp_data; txp->pdev =3D pdev; txp->regs =3D vc4_ioremap_regs(pdev, 0); if (IS_ERR(txp->regs)) @@ -519,7 +528,7 @@ static int vc4_txp_bind(struct device *dev, struct devi= ce *master, void *data) vc4_crtc->regset.regs =3D txp_regs; vc4_crtc->regset.nregs =3D ARRAY_SIZE(txp_regs); =20 - ret =3D vc4_crtc_init(drm, pdev, vc4_crtc, &vc4_txp_crtc_data, + ret =3D vc4_crtc_init(drm, pdev, vc4_crtc, &txp_data->base, &vc4_txp_crtc_funcs, &vc4_txp_crtc_helper_funcs, true); if (ret) return ret; @@ -579,7 +588,7 @@ static void vc4_txp_remove(struct platform_device *pdev) } =20 static const struct of_device_id vc4_txp_dt_match[] =3D { - { .compatible =3D "brcm,bcm2835-txp" }, + { .compatible =3D "brcm,bcm2835-txp", .data =3D &vc4_txp_data }, { /* sentinel */ }, }; =20 --=20 2.34.1