feat(dcache): update dcache api

Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
sakumisu
2025-06-04 15:16:01 +08:00
parent 06a0c4393b
commit 1d95077161
6 changed files with 65 additions and 15 deletions

View File

@@ -333,18 +333,9 @@
// #define CONFIG_USB_MUSB_SUNXI
/* ================ USB Dcache Configuration ==================*/
#ifdef CONFIG_USB_DCACHE_ENABLE
/* style 1*/
// void usb_dcache_clean(uintptr_t addr, uint32_t size);
// void usb_dcache_invalidate(uintptr_t addr, uint32_t size);
// void usb_dcache_flush(uintptr_t addr, uint32_t size);
/* style 2*/
// #define usb_dcache_clean(addr, size)
// #define usb_dcache_invalidate(addr, size)
// #define usb_dcache_flush(addr, size)
#endif
// #define CONFIG_USB_DCACHE_ENABLE
// #undef CONFIG_USB_ALIGN_SIZE
// #define CONFIG_USB_ALIGN_SIZE 32
#ifndef usb_phyaddr2ramaddr
#define usb_phyaddr2ramaddr(addr) (addr)

View File

@@ -10,6 +10,9 @@
#if CONFIG_USB_ALIGN_SIZE % 32
#error "CONFIG_USB_ALIGN_SIZE must be multiple of 32"
#endif
void usb_dcache_clean(uintptr_t addr, size_t size);
void usb_dcache_invalidate(uintptr_t addr, size_t size);
void usb_dcache_flush(uintptr_t addr, size_t size);
#else
#define usb_dcache_clean(addr, size)
#define usb_dcache_invalidate(addr, size)

View File

@@ -119,6 +119,7 @@ v1.5.0
- **重构device video 传输,直接在图像数据中填充 uvc header达到zero memcpy**
- **增加 usb_osal_thread_schedule_other api用于在释放 class 资源之前,先释放所有 class 线程,避免释放 class 资源以后线程还在使用该 class 资源**
- **dwc2 device 增加 dcache 功能,可用于 STM32H7/H7R/ESP32P4**
- **bouffalo/hpm/esp/st/nxp dcache api 支持**
- ch32 device iso 更新
- cmakesconskconfig 更新
- 使用 USB_ASSERT_MSG 对部分代码检查

View File

@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "bflb_core.h"
#include "bflb_l1c.h"
#include "usbh_core.h"
#include "hardware/usb_v2_reg.h"
@@ -141,3 +142,20 @@ uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port)
}
return USB_SPEED_HIGH;
}
#ifdef CONFIG_USB_DCACHE_ENABLE
void usb_dcache_clean(uintptr_t addr, size_t size)
{
bflb_l1c_dcache_clean_range((void *)addr, size);
}
void usb_dcache_invalidate(uintptr_t addr, size_t size)
{
bflb_l1c_dcache_invalidate_range((void *)addr, size);
}
void usb_dcache_flush(uintptr_t addr, size_t size)
{
bflb_l1c_dcache_clean_invalidate_range((void *)addr, size);
}
#endif

View File

@@ -6,6 +6,8 @@
*/
#include "hpm_common.h"
#include "hpm_soc.h"
#include "hpm_l1c_drv.h"
#include "usb_config.h"
void (*g_usb_hpm_irq[2])(uint8_t busid);
uint8_t g_usb_hpm_busid[2];
@@ -49,3 +51,20 @@ void hpm_isr_usb1(void)
g_usb_hpm_irq[1](g_usb_hpm_busid[1]);
}
#endif
#ifdef CONFIG_USB_DCACHE_ENABLE
void usb_dcache_clean(uintptr_t addr, size_t size)
{
l1c_dc_writeback(addr, size);
}
void usb_dcache_invalidate(uintptr_t addr, size_t size)
{
l1c_dc_invalidate(addr, size);
}
void usb_dcache_flush(uintptr_t addr, size_t size)
{
l1c_dc_flush(addr, size);
}
#endif

View File

@@ -6,6 +6,7 @@
#include "usbd_core.h"
#include "usbh_core.h"
#include "fsl_common.h"
#include "fsl_cache.h"
#include "usb_chipidea_reg.h"
__WEAK void USBD_IRQHandler(uint8_t busid)
@@ -429,3 +430,20 @@ void USB1_HS_IRQHandler(void)
{
g_usb_nxp_irq(0);
}
#ifdef CONFIG_USB_DCACHE_ENABLE
void usb_dcache_clean(uintptr_t addr, size_t size)
{
DCACHE_CleanByRange(addr, size);
}
void usb_dcache_invalidate(uintptr_t addr, size_t size)
{
DCACHE_InvalidateByRange(addr, size);
}
void usb_dcache_flush(uintptr_t addr, size_t size)
{
DCACHE_CleanInvalidateByRange(addr, size);
}
#endif