@@ -70,4 +70,52 @@ int camera_ext_clock_enable(void)
70
70
71
71
SYS_INIT (camera_ext_clock_enable , POST_KERNEL , CONFIG_CLOCK_CONTROL_PWM_INIT_PRIORITY );
72
72
73
- #endif
73
+ #endif
74
+
75
+ #if defined(CONFIG_SHARED_MULTI_HEAP )
76
+ #include <zephyr/kernel.h>
77
+ #include <zephyr/devicetree.h>
78
+ #include <zephyr/multi_heap/shared_multi_heap.h>
79
+
80
+ struct memory_region_t {
81
+ uintptr_t dt_addr ;
82
+ size_t dt_size ;
83
+ const char * dt_name ;
84
+ };
85
+
86
+ #define _BUILD_MEM_REGION (node_id ) \
87
+ { .dt_addr = DT_REG_ADDR(node_id), \
88
+ .dt_size = DT_REG_SIZE(node_id), \
89
+ .dt_name = DT_PROP(node_id, zephyr_memory_region) \
90
+ },
91
+
92
+ int smh_init (void )
93
+ {
94
+ int ret = 0 ;
95
+ ret = shared_multi_heap_pool_init ();
96
+ if (ret != 0 ) {
97
+ return ret ;
98
+ }
99
+
100
+ const struct memory_region_t regions [] = {
101
+ DT_FOREACH_STATUS_OKAY (zephyr_memory_region , _BUILD_MEM_REGION )
102
+ };
103
+
104
+ for (size_t i = 0 ; i < ARRAY_SIZE (regions ); i ++ ) {
105
+ if (!strncmp ("SDRAM" , regions [i ].dt_name , 5 )) {
106
+ struct shared_multi_heap_region smh_sdram = {
107
+ .addr = regions [i ].dt_addr ,
108
+ .size = regions [i ].dt_size ,
109
+ .attr = SMH_REG_ATTR_EXTERNAL ,
110
+ };
111
+ ret = shared_multi_heap_add (& smh_sdram , NULL );
112
+ if (ret != 0 ) {
113
+ return ret ;
114
+ }
115
+ }
116
+ }
117
+ return 0 ;
118
+ }
119
+
120
+ SYS_INIT (smh_init , POST_KERNEL , CONFIG_CLOCK_CONTROL_PWM_INIT_PRIORITY );
121
+ #endif
0 commit comments