@@ -209,10 +209,8 @@ static inline void dma_finish(const struct device *dev, struct i2c_msg *msg)
209
209
dma_stop (cfg -> rx_dma .dev_dma , cfg -> rx_dma .dma_channel );
210
210
LL_I2C_DisableDMAReq_RX (i2c );
211
211
#if defined(CONFIG_DCACHE ) && defined(CONFIG_I2C_STM32_V2_DMA )
212
- if (!buf_in_nocache ((uintptr_t )msg -> buf , msg -> len ) &&
212
+ if (!stm32_buf_in_nocache ((uintptr_t )msg -> buf , msg -> len ) &&
213
213
((msg -> flags & I2C_MSG_RW_MASK ) == I2C_MSG_READ )) {
214
- LOG_DBG ("Rx buffer at %p (len %zu) is in cached memory; invalidating cache" ,
215
- msg -> buf , msg -> len );
216
214
sys_cache_data_invd_range ((void * )msg -> buf , msg -> len );
217
215
}
218
216
#endif /* CONFIG_DCACHE && CONFIG_I2C_STM32_V2_DMA */
@@ -643,38 +641,6 @@ int i2c_stm32_error(const struct device *dev)
643
641
return - EIO ;
644
642
}
645
643
646
- #if defined(CONFIG_DCACHE ) && defined(CONFIG_I2C_STM32_V2_DMA )
647
- static bool buf_in_nocache (uintptr_t buf , size_t len_bytes )
648
- {
649
- bool buf_within_nocache = false;
650
-
651
- #ifdef CONFIG_NOCACHE_MEMORY
652
- /* Check if buffer is in nocache region defined by the linker */
653
- buf_within_nocache = (buf >= ((uintptr_t )_nocache_ram_start )) &&
654
- ((buf + len_bytes - 1 ) <= ((uintptr_t )_nocache_ram_end ));
655
- if (buf_within_nocache ) {
656
- return true;
657
- }
658
- #endif /* CONFIG_NOCACHE_MEMORY */
659
-
660
- #ifdef CONFIG_MEM_ATTR
661
- /* Check if buffer is in nocache memory region defined in DT */
662
- buf_within_nocache = mem_attr_check_buf (
663
- (void * )buf , len_bytes , DT_MEM_ARM (ATTR_MPU_RAM_NOCACHE )) == 0 ;
664
- if (buf_within_nocache ) {
665
- return true;
666
- }
667
- #endif /* CONFIG_MEM_ATTR */
668
-
669
- /* Check if buffer is in RO region (Flash..) */
670
- buf_within_nocache = (buf >= ((uintptr_t )__rodata_region_start )) &&
671
- ((buf + len_bytes - 1 ) <= ((uintptr_t )__rodata_region_end ));
672
-
673
- return buf_within_nocache ;
674
- }
675
- #endif /* CONFIG_DCACHE && CONFIG_I2C_STM32_V2_DMA */
676
-
677
-
678
644
static int stm32_i2c_irq_xfer (const struct device * dev , struct i2c_msg * msg ,
679
645
uint8_t * next_msg_flags , uint16_t slave )
680
646
{
@@ -695,10 +661,8 @@ static int stm32_i2c_irq_xfer(const struct device *dev, struct i2c_msg *msg,
695
661
#endif
696
662
697
663
#if defined(CONFIG_DCACHE ) && defined(CONFIG_I2C_STM32_V2_DMA )
698
- if (!buf_in_nocache ((uintptr_t )msg -> buf , msg -> len ) &&
664
+ if (!stm32_buf_in_nocache ((uintptr_t )msg -> buf , msg -> len ) &&
699
665
((msg -> flags & I2C_MSG_RW_MASK ) == I2C_MSG_WRITE )) {
700
- LOG_DBG ("Tx buffer at %p (len %zu) is in cached memory; cleaning cache" , msg -> buf ,
701
- msg -> len );
702
666
sys_cache_data_flush_range ((void * )msg -> buf , msg -> len );
703
667
}
704
668
#endif /* CONFIG_DCACHE && CONFIG_I2C_STM32_V2_DMA*/
0 commit comments