mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cunyuan Liu <cunyuan.liu@cixtech.com>
To: boris.brezillon@collabora.com, steven.price@arm.com,
	liviu.dudau@arm.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, gary.yang@cixtech.com,
	fugang.duan@cixtech.com
Cc: daniel.almeida@collabora.com, aliceryhl@google.com,
	p.zabel@pengutronix.de, dri-devel@lists.freedesktop.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	cix-kernel-upstream@cixtech.com, robin.wang@cixtech.com,
	cunyuan.liu@cixtech.com
Subject: [PATCH 2/3] drm/panthor: Add initial support for CIX Sky1
Date: Fri,  6 Nov 2026 18:47:34 +0800	[thread overview]
Message-ID: <20261106104735.1651267-3-cunyuan.liu@cixtech.com> (raw)
In-Reply-To: <20261106104735.1651267-1-cunyuan.liu@cixtech.com>

Add Sky1 SoC data to support the external reset and system-level cache
settings, and to skip devfreq.

The GPU on CIX Sky1 needs an external reset before the driver first
accesses the hardware. Without this reset, the GPU hardware cannot be
accessed correctly.

Configure SYSC_ALLOC before L2 power-on. Without these settings, GPU
rendering results are displayed incorrectly.

Keep the clock settings provided by the PM firmware. This first version
does not read OPPs or enable devfreq. It does not register a GPU cooling
device.

Tested on Orion O6: offscreen pixel readback, kmscube, glmark2 at 1080p,
runtime suspend and resume with a retained EGL context, software-triggered
reset-worker tests, and module unload and reload. Display tests used
local Komeda support.

Signed-off-by: Cunyuan Liu <cunyuan.liu@cixtech.com>
---
 drivers/gpu/drm/panthor/panthor_devfreq.c  | 11 +++++++++-
 drivers/gpu/drm/panthor/panthor_device.c   | 15 +++++++++++++
 drivers/gpu/drm/panthor/panthor_device.h   | 25 ++++++++++++++++++++++
 drivers/gpu/drm/panthor/panthor_drv.c      | 15 +++++++++++++
 drivers/gpu/drm/panthor/panthor_gpu.c      | 14 ++++++++++++
 drivers/gpu/drm/panthor/panthor_gpu_regs.h |  2 ++
 6 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panthor/panthor_devfreq.c b/drivers/gpu/drm/panthor/panthor_devfreq.c
index 2249b41ca4af..1914549f7b1f 100644
--- a/drivers/gpu/drm/panthor/panthor_devfreq.c
+++ b/drivers/gpu/drm/panthor/panthor_devfreq.c
@@ -154,6 +154,12 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
 
 	ptdev->devfreq = pdevfreq;
 
+	/* Keep the firmware clock settings until Sky1 devfreq is supported. */
+	if (ptdev->soc_data && ptdev->soc_data->skip_devfreq) {
+		ptdev->fast_rate = clk_get_rate(ptdev->clks.core);
+		return 0;
+	}
+
 	/*
 	 * The power domain associated with the GPU may have already added an
 	 * OPP table, complete with OPPs, as part of the platform bus
@@ -323,8 +329,11 @@ unsigned long panthor_devfreq_get_freq(struct panthor_device *ptdev)
 	unsigned long freq = 0;
 	int ret;
 
-	if (!pdevfreq->devfreq)
+	if (!pdevfreq->devfreq) {
+		if (ptdev->soc_data && ptdev->soc_data->skip_devfreq)
+			return clk_get_rate(ptdev->clks.core);
 		return 0;
+	}
 
 	ret = pdevfreq->devfreq->profile->get_cur_freq(ptdev->base.dev, &freq);
 	if (ret)
diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c
index 9687c59de350..1d682731a181 100644
--- a/drivers/gpu/drm/panthor/panthor_device.c
+++ b/drivers/gpu/drm/panthor/panthor_device.c
@@ -229,6 +229,13 @@ int panthor_device_init(struct panthor_device *ptdev)
 		return ret;
 	}
 
+	if (ptdev->soc_data && ptdev->soc_data->needs_external_reset) {
+		ptdev->reset_control = devm_reset_control_get_exclusive(ptdev->base.dev, NULL);
+		if (IS_ERR(ptdev->reset_control))
+			return dev_err_probe(ptdev->base.dev, PTR_ERR(ptdev->reset_control),
+					     "Failed to get GPU reset\n");
+	}
+
 	ret = panthor_devfreq_init(ptdev);
 	if (ret)
 		return ret;
@@ -511,6 +518,12 @@ int panthor_device_resume(struct device *dev)
 	if (ret)
 		goto err_disable_stacks_clk;
 
+	if (ptdev->reset_control && !panthor_device_is_initialized(ptdev)) {
+		ret = reset_control_reset(ptdev->reset_control);
+		if (ret)
+			goto err_disable_coregroup_clk;
+	}
+
 	panthor_devfreq_resume(ptdev);
 
 	if (panthor_device_is_initialized(ptdev) &&
@@ -553,6 +566,8 @@ int panthor_device_resume(struct device *dev)
 
 err_suspend_devfreq:
 	panthor_devfreq_suspend(ptdev);
+
+err_disable_coregroup_clk:
 	clk_disable_unprepare(ptdev->clks.coregroup);
 
 err_disable_stacks_clk:
diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h
index b55a3f9edd41..0923cc5df042 100644
--- a/drivers/gpu/drm/panthor/panthor_device.h
+++ b/drivers/gpu/drm/panthor/panthor_device.h
@@ -19,6 +19,8 @@
 #include <drm/gpu_scheduler.h>
 #include <drm/panthor_drm.h>
 
+struct reset_control;
+
 struct panthor_csf;
 struct panthor_csf_ctx;
 struct panthor_device;
@@ -34,10 +36,30 @@ struct panthor_pwr;
 struct panthor_vm;
 struct panthor_vm_pool;
 
+/**
+ * struct panthor_sysc_config - GPU system-cache configuration
+ */
+struct panthor_sysc_config {
+	/** @alloc: System-cache allocation policies for GPU access types. */
+	u32 alloc[8];
+};
+
 /**
  * struct panthor_soc_data - Panthor SoC Data
  */
 struct panthor_soc_data {
+	/**
+	 * @needs_external_reset: Reset the GPU after enabling its clocks
+	 * during initial probe.
+	 */
+	bool needs_external_reset;
+
+	/** @skip_devfreq: Keep the firmware clock settings without devfreq. */
+	bool skip_devfreq;
+
+	/** @sysc_config: System-cache configuration, or NULL to keep defaults. */
+	const struct panthor_sysc_config *sysc_config;
+
 	/** @asn_hash_enable: True if GPU_L2_CONFIG_ASN_HASH_ENABLE must be set. */
 	bool asn_hash_enable;
 
@@ -138,6 +160,9 @@ struct panthor_device {
 	/** @soc_data: Optional SoC data. */
 	const struct panthor_soc_data *soc_data;
 
+	/** @reset_control: Optional external GPU reset. */
+	struct reset_control *reset_control;
+
 	/** @phys_addr: Physical address of the iomem region. */
 	phys_addr_t phys_addr;
 
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index dc8d0191aef4..766df6505a7b 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -1872,12 +1872,27 @@ static struct attribute *panthor_attrs[] = {
 
 ATTRIBUTE_GROUPS(panthor);
 
+static const struct panthor_sysc_config sysc_config_cix_sky1 = {
+	/* Sky1 needs these SYSC_ALLOC policies for correct display of GPU output. */
+	.alloc = {
+		0x00230000, 0x00000023, 0x00000000, 0x00000000,
+		0x00523222, 0x00523200, 0x00000022, 0x00000032,
+	},
+};
+
+static const struct panthor_soc_data soc_data_cix_sky1 = {
+	.needs_external_reset = true,
+	.skip_devfreq = true,
+	.sysc_config = &sysc_config_cix_sky1,
+};
+
 static const struct panthor_soc_data soc_data_mediatek_mt8196 = {
 	.asn_hash_enable = true,
 	.asn_hash = { 0xb, 0xe, 0x0, },
 };
 
 static const struct of_device_id dt_match[] = {
+	{ .compatible = "cix,sky1-mali", .data = &soc_data_cix_sky1 },
 	{ .compatible = "mediatek,mt8196-mali", .data = &soc_data_mediatek_mt8196, },
 	{ .compatible = "rockchip,rk3588-mali" },
 	{ .compatible = "arm,mali-valhall-csf" },
diff --git a/drivers/gpu/drm/panthor/panthor_gpu.c b/drivers/gpu/drm/panthor/panthor_gpu.c
index a383b04f101e..9a6963fe62ae 100644
--- a/drivers/gpu/drm/panthor/panthor_gpu.c
+++ b/drivers/gpu/drm/panthor/panthor_gpu.c
@@ -63,6 +63,19 @@ static void panthor_gpu_coherency_set(struct panthor_device *ptdev)
 		  ptdev->gpu_info.selected_coherency);
 }
 
+static void panthor_gpu_sysc_config_set(struct panthor_device *ptdev)
+{
+	const struct panthor_sysc_config *config;
+	unsigned int i;
+
+	if (!ptdev->soc_data || !ptdev->soc_data->sysc_config)
+		return;
+
+	config = ptdev->soc_data->sysc_config;
+	for (i = 0; i < ARRAY_SIZE(config->alloc); i++)
+		gpu_write(ptdev->gpu->iomem, GPU_SYSC_ALLOC(i), config->alloc[i]);
+}
+
 static void panthor_gpu_l2_config_set(struct panthor_device *ptdev)
 {
 	struct panthor_gpu *gpu = ptdev->gpu;
@@ -317,6 +330,7 @@ int panthor_gpu_l2_power_on(struct panthor_device *ptdev)
 	}
 
 	/* Set the desired coherency mode and L2 config before the power up of L2 */
+	panthor_gpu_sysc_config_set(ptdev);
 	panthor_gpu_coherency_set(ptdev);
 	panthor_gpu_l2_config_set(ptdev);
 
diff --git a/drivers/gpu/drm/panthor/panthor_gpu_regs.h b/drivers/gpu/drm/panthor/panthor_gpu_regs.h
index 4c5b953796e4..f9b65a4dae83 100644
--- a/drivers/gpu/drm/panthor/panthor_gpu_regs.h
+++ b/drivers/gpu/drm/panthor/panthor_gpu_regs.h
@@ -116,4 +116,6 @@
 #define   GPU_COHERENCY_ACE				1
 #define   GPU_COHERENCY_NONE				31
 
+#define GPU_SYSC_ALLOC(n)				(0x340 + (n) * 4)
+
 #endif /* __PANTHOR_GPU_REGS_H__ */
-- 
2.53.0


  parent reply	other threads:[~2026-11-06 10:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 10:47 [PATCH 0/3] Add initial GPU " Cunyuan Liu
2026-11-06 10:47 ` [PATCH 1/3] dt-bindings: gpu: Add CIX Sky1 Mali support Cunyuan Liu
2026-11-06 17:17   ` Conor Dooley
2026-11-06 10:47 ` Cunyuan Liu [this message]
2026-11-06 12:04   ` [PATCH 2/3] drm/panthor: Add initial support for CIX Sky1 Philipp Zabel
2026-11-06 13:02     ` Cunyuan Liu (刘存原)
2026-11-06 10:47 ` [PATCH 3/3] arm64: dts: cix: Add GPU support for Sky1 Orion O6 Cunyuan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106104735.1651267-3-cunyuan.liu@cixtech.com \
    --to=cunyuan.liu@cixtech.com \
    --cc=aliceryhl@google.com \
    --cc=boris.brezillon@collabora.com \
    --cc=cix-kernel-upstream@cixtech.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fugang.duan@cixtech.com \
    --cc=gary.yang@cixtech.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=robin.wang@cixtech.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=steven.price@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®