Skip to content

Commit 0103de7

Browse files
etienne-lmskartben
authored andcommitted
drivers: i2c: stm32: support DMA when CONFIG_MEM_ATTR=n
Allow STM32 I2C driver v2 to operate with DMA support even when CONFIG_MEM_ATTR is disabled which happen when CONFIG_ARM_MPU is intentionally disabled despite the CPU supports MPU. By the way, remove a #ifdef directive on header files inclusion that adds noise in the header file inclusion section without any benefit. Signed-off-by: Etienne Carriere <[email protected]>
1 parent bec3a6f commit 0103de7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/i2c/i2c_ll_stm32_v2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
#include <zephyr/pm/device_runtime.h>
2222
#include "i2c_ll_stm32.h"
2323

24-
#if defined(CONFIG_DCACHE) && defined(CONFIG_I2C_STM32_V2_DMA)
2524
#include <zephyr/cache.h>
2625
#include <zephyr/linker/linker-defs.h>
2726
#include <zephyr/mem_mgmt/mem_attr.h>
2827
#include <zephyr/dt-bindings/memory-attr/memory-attr-arm.h>
29-
#endif
3028

3129
#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
3230
#include <zephyr/logging/log.h>
@@ -697,12 +695,14 @@ static bool buf_in_nocache(uintptr_t buf, size_t len_bytes)
697695
}
698696
#endif /* CONFIG_NOCACHE_MEMORY */
699697

698+
#ifdef CONFIG_MEM_ATTR
700699
/* Check if buffer is in nocache memory region defined in DT */
701700
buf_within_nocache = mem_attr_check_buf(
702701
(void *)buf, len_bytes, DT_MEM_ARM(ATTR_MPU_RAM_NOCACHE)) == 0;
703702
if (buf_within_nocache) {
704703
return true;
705704
}
705+
#endif /* CONFIG_MEM_ATTR */
706706

707707
/* Check if buffer is in RO region (Flash..) */
708708
buf_within_nocache = (buf >= ((uintptr_t)__rodata_region_start)) &&

0 commit comments

Comments
 (0)