From b50e681fb588da49c7fcbf71bd6a7b499600a6c4 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Tue, 3 Nov 2026 03:55:14 -0600 Subject: [PATCH] soc: apple: show the fabric and DCS clock-generator words in debugfs Read only: apple-pmgr-misc gets one debugfs directory with the whole clock-generator word of the fabric and DCS system devices (fabric_ps and dcs_ps, mode 0400, the desired state in bits 3:0 and the actual state in bits 7:4). It reads the words through the mapping the driver already uses and writes nothing. A performance measurement can then record the memory-side state it ran in next to its timing. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> --- drivers/soc/apple/apple-pmgr-misc.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/soc/apple/apple-pmgr-misc.c b/drivers/soc/apple/apple-pmgr-misc.c index 53170aad4d4b4f..a659defa6a63c6 100644 --- a/drivers/soc/apple/apple-pmgr-misc.c +++ b/drivers/soc/apple/apple-pmgr-misc.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -465,6 +467,37 @@ static bool apple_pmgr_init_device(struct apple_pmgr_misc *misc, return true; } +/* Read only: the whole clock-generator word of one system device (the desired state is bits 3:0, the actual state bits 7:4), no side effect. */ +static int apple_pmgr_misc_ps_show(struct seq_file *s, void *unused) +{ + const struct apple_pmgr_sys_device *d = s->private; + + seq_printf(s, "%#010x\n", readl_relaxed(d->base + APPLE_CLKGEN_PSTATE)); + return 0; +} +DEFINE_SHOW_ATTRIBUTE(apple_pmgr_misc_ps); + +static void apple_pmgr_misc_debugfs_remove(void *dir) +{ + debugfs_remove(dir); +} + +static void apple_pmgr_misc_debugfs_init(struct apple_pmgr_misc *misc) +{ + static const char * const names[DEV_MAX] = { "fabric_ps", "dcs_ps" }; + char *dirname = devm_kasprintf(misc->dev, GFP_KERNEL, "apple-pmgr-misc-%s", dev_name(misc->dev)); + struct dentry *dir; + int i; + + if (!dirname) + return; + dir = debugfs_create_dir(dirname, NULL); + for (i = 0; i < DEV_MAX; i++) + if (misc->devices[i].base) + debugfs_create_file(names[i], 0400, dir, &misc->devices[i], &apple_pmgr_misc_ps_fops); + devm_add_action_or_reset(misc->dev, apple_pmgr_misc_debugfs_remove, dir); +} + static int apple_pmgr_misc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -486,6 +519,9 @@ static int apple_pmgr_misc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, misc); + if (!ret) + apple_pmgr_misc_debugfs_init(misc); + /* * With PMP enabled its firmware owns the fabric and DCS p-states. * Writing them for suspend as well leaves the system unable to resume