@@ -114,14 +114,15 @@ TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_update(dwc2_regs_t* dwc2, uint
114114//--------------------------------------------------------------------+
115115// Data Cache
116116//--------------------------------------------------------------------+
117+ #if CFG_TUD_DWC2_DMA_ENABLE || CFG_TUH_DWC2_DMA_ENABLE
117118#if defined(SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE ) && SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
118- #include "sdkconfig.h"
119119#include "hal/cache_hal.h"
120120#include "esp_cache.h"
121- #include "esp_log.h"
122121
123- #define DWC2_MEM_CACHE_LINE_SIZE CONFIG_CACHE_L1_CACHE_LINE_SIZE
124- #define DWC2_ENABLE_MEM_CACHE 1
122+ #if CFG_TUD_MEM_DCACHE_LINE_SIZE != CONFIG_CACHE_L1_CACHE_LINE_SIZE || \
123+ CFG_TUH_MEM_DCACHE_LINE_SIZE != CONFIG_CACHE_L1_CACHE_LINE_SIZE
124+ #error "CFG_TUD/TUH_MEM_DCACHE_LINE_SIZE must match CONFIG_CACHE_L1_CACHE_LINE_SIZE"
125+ #endif
125126
126127TU_ATTR_ALWAYS_INLINE static inline uint32_t round_up_to_cache_line_size (uint32_t size ) {
127128 if (size & (CONFIG_CACHE_L1_CACHE_LINE_SIZE - 1 )) {
@@ -131,29 +132,25 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t round_up_to_cache_line_size(uint32_
131132}
132133
133134TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcache_clean (const void * addr , uint32_t data_size ) {
134- // round up to cache line size
135135 const int flag = ESP_CACHE_MSYNC_FLAG_TYPE_DATA | ESP_CACHE_MSYNC_FLAG_DIR_C2M ;
136136 data_size = round_up_to_cache_line_size (data_size );
137- //ESP_EARLY_LOGI("ESP32_DWC", "dcache clean, addr 0x%"PRIx32", size %d (%s)", (uintptr_t)addr, data_size);
138137 assert (ESP_OK == esp_cache_msync ((void * )addr , data_size , flag ));
139138}
140139
141140TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcache_invalidate (const void * addr , uint32_t data_size ) {
142141 const int flag = ESP_CACHE_MSYNC_FLAG_TYPE_DATA | ESP_CACHE_MSYNC_FLAG_DIR_M2C ;
143142 data_size = round_up_to_cache_line_size (data_size );
144- //ESP_EARLY_LOGI("ESP32_DWC", "dcache invalidate, addr 0x%"PRIx32", size %d (%s)", (uintptr_t)addr, data_size);
145143 assert (ESP_OK == esp_cache_msync ((void * )addr , data_size , flag ));
146144}
147145
148146TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcache_clean_invalidate (const void * addr , uint32_t data_size ) {
149147 const int flag = ESP_CACHE_MSYNC_FLAG_TYPE_DATA | ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_DIR_M2C ;
150148 data_size = round_up_to_cache_line_size (data_size );
151- //ESP_EARLY_LOGI("ESP32_DWC", "dcache clean_invalidate, addr 0x%"PRIx32", size %d (%s)", (uintptr_t)addr, data_size);
152149 assert (ESP_OK == esp_cache_msync ((void * )addr , data_size , flag ));
153150}
154151
155- #endif // SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
156-
152+ #endif
153+ #endif
157154
158155#ifdef __cplusplus
159156}
0 commit comments