summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2025-10-30 21:33:23 +0800
committersakumisu <[email protected]>2025-11-01 00:22:19 +0800
commit84b1d3feebe6b3fb23f9f01c13033fffa9efdbbe (patch)
tree9a2a6107571285326f268ecb837d3a4badbd6f66
parent1045f877c88d43fde8440a7d1341261c867cadd2 (diff)
update(port/chipidea): add dcache support for device
Signed-off-by: sakumisu <[email protected]>
-rw-r--r--port/chipidea/usb_dc_chipidea.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/port/chipidea/usb_dc_chipidea.c b/port/chipidea/usb_dc_chipidea.c
index 106f8af5..31c3f00c 100644
--- a/port/chipidea/usb_dc_chipidea.c
+++ b/port/chipidea/usb_dc_chipidea.c
@@ -594,10 +594,15 @@ int usbd_ep_start_write(uint8_t busid, const uint8_t ep, const uint8_t *data, ui
return -2;
}
+#ifdef CONFIG_USB_DCACHE_ENABLE
+ USB_ASSERT_MSG(!((uintptr_t)data % CONFIG_USB_ALIGN_SIZE), "data is not aligned %d", CONFIG_USB_ALIGN_SIZE);
+#endif
+
g_chipidea_udc[busid].in_ep[ep_idx].xfer_buf = (uint8_t *)data;
g_chipidea_udc[busid].in_ep[ep_idx].xfer_len = data_len;
g_chipidea_udc[busid].in_ep[ep_idx].actual_xfer_len = 0;
+ usb_dcache_clean((uintptr_t)data, USB_ALIGN_UP(data_len, CONFIG_USB_ALIGN_SIZE));
chipidea_start_xfer(busid, ep, (uint8_t *)data, data_len);
return 0;
@@ -614,10 +619,15 @@ int usbd_ep_start_read(uint8_t busid, const uint8_t ep, uint8_t *data, uint32_t
return -2;
}
+#ifdef CONFIG_USB_DCACHE_ENABLE
+ USB_ASSERT_MSG(!((uintptr_t)data % CONFIG_USB_ALIGN_SIZE), "data is not aligned %d", CONFIG_USB_ALIGN_SIZE);
+#endif
+
g_chipidea_udc[busid].out_ep[ep_idx].xfer_buf = (uint8_t *)data;
g_chipidea_udc[busid].out_ep[ep_idx].xfer_len = data_len;
g_chipidea_udc[busid].out_ep[ep_idx].actual_xfer_len = 0;
+ usb_dcache_invalidate((uintptr_t)data, USB_ALIGN_UP(data_len, CONFIG_USB_ALIGN_SIZE));
chipidea_start_xfer(busid, ep, data, data_len);
return 0;
@@ -712,6 +722,7 @@ void USBD_IRQHandler(uint8_t busid)
if (ep_addr & 0x80) {
usbd_event_ep_in_complete_handler(busid, ep_addr, transfer_len);
} else {
+ usb_dcache_invalidate((uintptr_t)g_chipidea_udc[busid].out_ep[ep_idx].xfer_buf, USB_ALIGN_UP(transfer_len, CONFIG_USB_ALIGN_SIZE));
usbd_event_ep_out_complete_handler(busid, ep_addr, transfer_len);
}
}