Skip to content

Commit 0b4a918

Browse files
travis3630nordicjm
authored andcommitted
[nrf fromtree] drivers: cache: nrf: Resolve NRF_CACHE_HAS_LINEADDR issue
Add new function called _cache_all_check that cache all if NRF_CACHE has no LINEADDR. Signed-off-by: Travis Lam <[email protected]> (cherry picked from commit 10f35d7)
1 parent 39150f2 commit 0b4a918

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

drivers/cache/cache_nrf.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static inline int _cache_all(NRF_CACHE_Type *cache, enum k_nrf_cache_op op)
9494
return 0;
9595
}
9696

97+
#if NRF_CACHE_HAS_LINEADDR
9798
static inline void _cache_line(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, uintptr_t line_addr)
9899
{
99100
do {
@@ -160,7 +161,7 @@ static inline int _cache_checks(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, v
160161
size_t size, bool is_range)
161162
{
162163
/* Check if the cache is enabled */
163-
if (!(cache->ENABLE & CACHE_ENABLE_ENABLE_Enabled)) {
164+
if (!nrf_cache_enable_check(cache)) {
164165
return -EAGAIN;
165166
}
166167

@@ -175,6 +176,16 @@ static inline int _cache_checks(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, v
175176

176177
return _cache_range(cache, op, addr, size);
177178
}
179+
#else
180+
static inline int _cache_all_checks(NRF_CACHE_Type *cache, enum k_nrf_cache_op op)
181+
{
182+
/* Check if the cache is enabled */
183+
if (!nrf_cache_enable_check(cache)) {
184+
return -EAGAIN;
185+
}
186+
return _cache_all(cache, op);
187+
}
188+
#endif /* NRF_CACHE_HAS_LINEADDR */
178189

179190
#if defined(NRF_DCACHE) && NRF_CACHE_HAS_TASKS
180191

@@ -296,29 +307,41 @@ void cache_instr_disable(void)
296307
int cache_instr_flush_all(void)
297308
{
298309
#if NRF_CACHE_HAS_TASK_CLEAN
310+
#if NRF_CACHE_HAS_LINEADDR
299311
return _cache_checks(NRF_ICACHE, K_NRF_CACHE_CLEAN, NULL, 0, false);
312+
#else
313+
return _cache_all_checks(NRF_ICACHE, K_NRF_CACHE_CLEAN);
314+
#endif
300315
#else
301316
return -ENOTSUP;
302317
#endif
303318
}
304319

305320
int cache_instr_invd_all(void)
306321
{
322+
#if NRF_CACHE_HAS_LINEADDR
307323
return _cache_checks(NRF_ICACHE, K_NRF_CACHE_INVD, NULL, 0, false);
324+
#else
325+
return _cache_all_checks(NRF_ICACHE, K_NRF_CACHE_INVD);
326+
#endif
308327
}
309328

310329
int cache_instr_flush_and_invd_all(void)
311330
{
312331
#if NRF_CACHE_HAS_TASK_FLUSH
332+
#if NRF_CACHE_HAS_LINEADDR
313333
return _cache_checks(NRF_ICACHE, K_NRF_CACHE_FLUSH, NULL, 0, false);
334+
#else
335+
return _cache_all_checks(NRF_ICACHE, K_NRF_CACHE_FLUSH);
336+
#endif
314337
#else
315338
return -ENOTSUP;
316339
#endif
317340
}
318341

319342
int cache_instr_flush_range(void *addr, size_t size)
320343
{
321-
#if NRF_CACHE_HAS_TASK_CLEAN
344+
#if NRF_CACHE_HAS_TASK_CLEAN && NRF_CACHE_HAS_LINEADDR
322345
return _cache_checks(NRF_ICACHE, K_NRF_CACHE_CLEAN, addr, size, true);
323346
#else
324347
return -ENOTSUP;
@@ -327,12 +350,16 @@ int cache_instr_flush_range(void *addr, size_t size)
327350

328351
int cache_instr_invd_range(void *addr, size_t size)
329352
{
353+
#if NRF_CACHE_HAS_LINEADDR
330354
return _cache_checks(NRF_ICACHE, K_NRF_CACHE_INVD, addr, size, true);
355+
#else
356+
return -ENOTSUP;
357+
#endif
331358
}
332359

333360
int cache_instr_flush_and_invd_range(void *addr, size_t size)
334361
{
335-
#if NRF_CACHE_HAS_TASK_FLUSH
362+
#if NRF_CACHE_HAS_TASK_FLUSH && NRF_CACHE_HAS_LINEADDR
336363
return _cache_checks(NRF_ICACHE, K_NRF_CACHE_FLUSH, addr, size, true);
337364
#else
338365
return -ENOTSUP;

0 commit comments

Comments
 (0)