Skip to content

Commit b9d6c47

Browse files
committed
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: Daniel 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
1 parent e446556 commit b9d6c47

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

drivers/soc/rockchip/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,12 @@ config ROCKCHIP_PM_DOMAINS
3434

3535
If unsure, say N.
3636

37+
config ROCKCHIP_DTPM
38+
tristate "Rockchip DTPM hierarchy"
39+
depends on DTPM && m
40+
help
41+
Describe the hierarchy for the Dynamic Thermal Power
42+
Management tree on this platform. That will create all the
43+
power capping capable devices.
44+
3745
endif

drivers/soc/rockchip/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
obj-$(CONFIG_ROCKCHIP_GRF) += grf.o
66
obj-$(CONFIG_ROCKCHIP_IODOMAIN) += io-domain.o
77
obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
8+
obj-$(CONFIG_ROCKCHIP_DTPM) += dtpm.o

drivers/soc/rockchip/dtpm.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright 2021 Linaro Limited
4+
*
5+
* Author: Daniel Lezcano <daniel.lezcano@linaro.org>
6+
*
7+
* DTPM hierarchy description
8+
*/
9+
#include <linux/dtpm.h>
10+
#include <linux/module.h>
11+
#include <linux/of.h>
12+
#include <linux/platform_device.h>
13+
14+
static struct dtpm_node __initdata rk3399_hierarchy[] = {
15+
[0]{ .name = "rk3399",
16+
.type = DTPM_NODE_VIRTUAL },
17+
[1]{ .name = "package",
18+
.type = DTPM_NODE_VIRTUAL,
19+
.parent = &rk3399_hierarchy[0] },
20+
[2]{ .name = "/cpus/cpu@0",
21+
.type = DTPM_NODE_DT,
22+
.parent = &rk3399_hierarchy[1] },
23+
[3]{ .name = "/cpus/cpu@1",
24+
.type = DTPM_NODE_DT,
25+
.parent = &rk3399_hierarchy[1] },
26+
[4]{ .name = "/cpus/cpu@2",
27+
.type = DTPM_NODE_DT,
28+
.parent = &rk3399_hierarchy[1] },
29+
[5]{ .name = "/cpus/cpu@3",
30+
.type = DTPM_NODE_DT,
31+
.parent = &rk3399_hierarchy[1] },
32+
[6]{ .name = "/cpus/cpu@100",
33+
.type = DTPM_NODE_DT,
34+
.parent = &rk3399_hierarchy[1] },
35+
[7]{ .name = "/cpus/cpu@101",
36+
.type = DTPM_NODE_DT,
37+
.parent = &rk3399_hierarchy[1] },
38+
[8]{ .name = "/gpu@ff9a0000",
39+
.type = DTPM_NODE_DT,
40+
.parent = &rk3399_hierarchy[1] },
41+
[9]{ /* sentinel */ }
42+
};
43+
44+
static struct of_device_id __initdata rockchip_dtpm_match_table[] = {
45+
{ .compatible = "rockchip,rk3399", .data = rk3399_hierarchy },
46+
{},
47+
};
48+
49+
static int __init rockchip_dtpm_init(void)
50+
{
51+
return dtpm_create_hierarchy(rockchip_dtpm_match_table);
52+
}
53+
module_init(rockchip_dtpm_init);
54+
55+
MODULE_SOFTDEP("pre: panfrost cpufreq-dt");
56+
MODULE_DESCRIPTION("Rockchip DTPM driver");
57+
MODULE_LICENSE("GPL");
58+
MODULE_ALIAS("platform:dtpm");
59+
MODULE_AUTHOR("Daniel Lezcano <daniel.lezcano@kernel.org");

0 commit comments

Comments
 (0)