xref: /openbmc/linux/drivers/soc/rockchip/dtpm.c (revision 185c8f33)
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 static void __exit rockchip_dtpm_exit(void)
56 {
57 	return dtpm_destroy_hierarchy();
58 }
59 module_exit(rockchip_dtpm_exit);
60 
61 MODULE_SOFTDEP("pre: panfrost cpufreq-dt");
62 MODULE_DESCRIPTION("Rockchip DTPM driver");
63 MODULE_LICENSE("GPL");
64 MODULE_ALIAS("platform:dtpm");
65 MODULE_AUTHOR("Daniel Lezcano <daniel.lezcano@kernel.org");
66