File tree Expand file tree Collapse file tree 6 files changed +110
-0
lines changed
samples/subsys/cpu_freq/on_demand Expand file tree Collapse file tree 6 files changed +110
-0
lines changed Original file line number Diff line number Diff line change 96
96
<1 0 &gpio2 1 0>, /* AIN1 */
97
97
<0 0 &gpio2 0 0>; /* AIN0 */
98
98
};
99
+
100
+ performance-states {
101
+ pstate_0: pstate_0 {
102
+ compatible = "adi,max32-pstate";
103
+ load-threshold = <50>;
104
+ pstate-id = <0>;
105
+ };
106
+ pstate_1: pstate_1 {
107
+ compatible = "adi,max32-pstate";
108
+ load-threshold = <20>;
109
+ pstate-id = <1>;
110
+ };
111
+ pstate_2: pstate_2 {
112
+ compatible = "adi,max32-pstate";
113
+ load-threshold = <0>;
114
+ pstate-id = <2>;
115
+ };
116
+ };
99
117
};
100
118
101
119
&uart0 {
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2025 Analog Devices, Inc.
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ description : Max32 custom properties for performance state (pstate)
6
+
7
+ compatible : " adi,max32-pstate"
8
+
9
+ include : " zephyr,pstate.yaml"
10
+
11
+ properties :
12
+ pstate-id :
13
+ type : int
14
+ required : true
15
+ description : |
16
+ Identifier of performance state which maps to a divider setting.
Original file line number Diff line number Diff line change 4
4
tests :
5
5
sample.cpu_freq :
6
6
tags : cpu_freq
7
+ platform_allow :
8
+ - max32655fthr/max32655/m4
Original file line number Diff line number Diff line change @@ -14,3 +14,8 @@ if(CONFIG_SOC_MAX78000 OR CONFIG_SOC_MAX78002)
14
14
endif ()
15
15
16
16
set (SOC_LINKER_SCRIPT ${ZEPHYR_BASE} /include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "" )
17
+
18
+ if (CONFIG_SOC_MAX32655 )
19
+ zephyr_library_sources_ifdef (CONFIG_CPU_FREQ max32655/cpu_freq.c )
20
+ zephyr_include_directories (max32655 )
21
+ endif ()
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2025 Analog Devices, Inc.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #include <zephyr/kernel.h>
8
+ #include <zephyr/devicetree.h>
9
+ #include <zephyr/cpu_freq/cpu_freq.h>
10
+ #include <zephyr/cpu_freq/pstate.h>
11
+ #include <zephyr/logging/log.h>
12
+
13
+ #include "mxc_sys.h"
14
+
15
+ LOG_MODULE_REGISTER (max32655_cpu_freq , CONFIG_CPU_FREQ_LOG_LEVEL );
16
+
17
+ struct max32_config {
18
+ int state_id ;
19
+ };
20
+
21
+ int32_t cpu_freq_pstate_set (struct pstate state )
22
+ {
23
+ int state_id = ((const struct max32_config * )state .config )-> state_id ;
24
+
25
+ LOG_DBG ("Setting performance state: %d" , state_id );
26
+
27
+ switch (state_id ) {
28
+ case 0 :
29
+ LOG_DBG ("Setting P-state 0: Nominal Mode" );
30
+ break ;
31
+ case 1 :
32
+ LOG_DBG ("Setting P-state 1: Low Power Mode" );
33
+ break ;
34
+ case 2 :
35
+ LOG_DBG ("Setting P-state 2: Ultra-low Power Mode" );
36
+ break ;
37
+ default :
38
+ LOG_ERR ("Unsupported P-state: %d" , state_id );
39
+ return -1 ;
40
+ }
41
+
42
+ return 0 ;
43
+ }
44
+
45
+ #define DEFINE_MAX32_CONFIG (node_id ) \
46
+ static const struct max32_config _CONCAT(max32_config_, node_id) = { \
47
+ .state_id = DT_PROP(node_id, pstate_id), \
48
+ }; \
49
+ PSTATE_DT_DEFINE(node_id, &_CONCAT(max32_config_, node_id))
50
+
51
+ DT_FOREACH_CHILD (DT_PATH (performance_states ), DEFINE_MAX32_CONFIG )
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2025 Analog Devices, Inc.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #ifndef ZEPHYR_CPU_FREQ_SOC_H__
8
+ #define ZEPHYR_CPU_FREQ_SOC_H__
9
+
10
+ #include <zephyr/cpu_freq/pstate.h>
11
+
12
+ /* Define performance-states as extern to be picked up by CPU Freq policy */
13
+ #define DECLARE_PSTATE_EXTERN (node_id ) \
14
+ extern const struct pstate _CONCAT(pstate_, DEVICE_DT_NAME_GET(node_id));
15
+
16
+ DT_FOREACH_CHILD (DT_PATH (performance_states ), DECLARE_PSTATE_EXTERN )
17
+
18
+ #endif /* ZEPHYR_CPU_FREQ_SOC_H__ */
You can’t perform that action at this time.
0 commit comments