Skip to content

Commit 1bc008d

Browse files
ccli8fabiobaltieri
authored andcommitted
drivers: misc: ethos_u: support default dcache flush/invalidate
This provides default ethosu_flush_dcache and ethosu_invalidate_dcache overrides. User application can disable it through Kconfig option if it needs to provide its own. Signed-off-by: Chun-Chieh Li <[email protected]>
1 parent f6bee98 commit 1bc008d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

drivers/misc/ethos_u/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ config ETHOS_U_NUMAKER
1818
Enables Nuvoton NuMaker frontend of Arm Ethos-U NPU driver
1919

2020
endchoice
21+
22+
config ETHOS_U_DCACHE
23+
bool "Override Ethos-U driver DCache functions"
24+
depends on ETHOS_U
25+
default y if CACHE_MANAGEMENT

drivers/misc/ethos_u/ethos_u_common.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <zephyr/devicetree.h>
1010
#include <zephyr/kernel.h>
1111
#include <zephyr/sys/util.h>
12+
#include <zephyr/cache.h>
1213

1314
#include <ethosu_driver.h>
1415

@@ -100,3 +101,19 @@ int ethosu_semaphore_give(void *sem)
100101
k_sem_give((struct k_sem *)sem);
101102
return 0;
102103
}
104+
105+
#if defined(CONFIG_ETHOS_U_DCACHE)
106+
void ethosu_flush_dcache(uint32_t *p, size_t bytes)
107+
{
108+
if (p && bytes) {
109+
sys_cache_data_flush_range((void *)p, bytes);
110+
}
111+
}
112+
113+
void ethosu_invalidate_dcache(uint32_t *p, size_t bytes)
114+
{
115+
if (p && bytes) {
116+
sys_cache_data_invd_range((void *)p, bytes);
117+
}
118+
}
119+
#endif

0 commit comments

Comments
 (0)