Commit b9d6c47a authored by Daniel Lezcano's avatar Daniel Lezcano
Browse files

rockchip/soc/drivers: Add DTPM description for rk3399



The DTPM framework does support now the hierarchy description.

The platform specific code can call the hierarchy creation function
with an array of struct dtpm_node pointing to their parent.

This patch provides a description of the big / Little CPUs and the
GPU and tie them together under a virtual 'package' name. Only rk3399 is
described now.

The description could be extended in the future with the memory
controller with devfreq.

The description is always a module and it describes the soft
dependencies. The userspace has to load the softdeps module in the
right order.

Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by; Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20220128163537.212248-6-daniel.lezcano@linaro.org
parent e4465561
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -34,4 +34,12 @@ config ROCKCHIP_PM_DOMAINS

          If unsure, say N.

config ROCKCHIP_DTPM
	tristate "Rockchip DTPM hierarchy"
	depends on DTPM && m
	help
	 Describe the hierarchy for the Dynamic Thermal Power
	 Management tree on this platform. That will create all the
	 power capping capable devices.

endif
+1 −0
Original line number Diff line number Diff line
@@ -5,3 +5,4 @@
obj-$(CONFIG_ROCKCHIP_GRF) += grf.o
obj-$(CONFIG_ROCKCHIP_IODOMAIN) += io-domain.o
obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
obj-$(CONFIG_ROCKCHIP_DTPM) += dtpm.o
+59 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2021 Linaro Limited
 *
 * Author: Daniel Lezcano <daniel.lezcano@linaro.org>
 *
 * DTPM hierarchy description
 */
#include <linux/dtpm.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>

static struct dtpm_node __initdata rk3399_hierarchy[] = {
	[0]{ .name = "rk3399",
	     .type = DTPM_NODE_VIRTUAL },
	[1]{ .name = "package",
	     .type = DTPM_NODE_VIRTUAL,
	     .parent = &rk3399_hierarchy[0] },
	[2]{ .name = "/cpus/cpu@0",
	     .type = DTPM_NODE_DT,
	     .parent = &rk3399_hierarchy[1] },
	[3]{ .name = "/cpus/cpu@1",
	     .type = DTPM_NODE_DT,
	     .parent = &rk3399_hierarchy[1] },
	[4]{ .name = "/cpus/cpu@2",
	     .type = DTPM_NODE_DT,
	     .parent = &rk3399_hierarchy[1] },
	[5]{ .name = "/cpus/cpu@3",
	     .type = DTPM_NODE_DT,
	     .parent = &rk3399_hierarchy[1] },
	[6]{ .name = "/cpus/cpu@100",
	     .type = DTPM_NODE_DT,
	     .parent = &rk3399_hierarchy[1] },
	[7]{ .name = "/cpus/cpu@101",
	     .type = DTPM_NODE_DT,
	     .parent = &rk3399_hierarchy[1] },
	[8]{ .name = "/gpu@ff9a0000",
	     .type = DTPM_NODE_DT,
	     .parent = &rk3399_hierarchy[1] },
	[9]{ /* sentinel */ }
};

static struct of_device_id __initdata rockchip_dtpm_match_table[] = {
        { .compatible = "rockchip,rk3399", .data = rk3399_hierarchy },
        {},
};

static int __init rockchip_dtpm_init(void)
{
	return dtpm_create_hierarchy(rockchip_dtpm_match_table);
}
module_init(rockchip_dtpm_init);

MODULE_SOFTDEP("pre: panfrost cpufreq-dt");
MODULE_DESCRIPTION("Rockchip DTPM driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:dtpm");
MODULE_AUTHOR("Daniel Lezcano <daniel.lezcano@kernel.org");