This commit is contained in:
刘可亮
2024-01-27 08:47:24 +08:00
parent d3bd993b5f
commit 9f7ba67007
2345 changed files with 74421 additions and 76616 deletions

View File

@@ -253,7 +253,7 @@ int usb_hc_hw_init(int id)
g_asynchead.hw.overlay.token = (QH_TOKEN_HALTED);
g_asynchead.fqp = (QTD_NQP_T);
aicos_dcache_clean_range((void *)(uintptr_t)&g_asynchead.hw,
sizeof(struct usb_ehci_qh_s));
ROUNDUP(sizeof(struct usb_ehci_qh_s), CACHE_LINE_SIZE));
/* Host Controller Initialization. Paragraph 4.1 */
@@ -559,7 +559,7 @@ static int usb_ehci_qtd_foreach(struct usb_ehci_qh_s *qh, foreach_qtd_t handler,
static int usb_ehci_qtd_discard(struct usb_ehci_qtd_s *qtd, u32 **bp, void *arg)
{
aicos_dcache_clean_invalid_range((void *)&qtd->hw,
sizeof(struct usb_ehci_qtd_s));
ROUNDUP(sizeof(struct usb_ehci_qtd_s), CACHE_LINE_SIZE));
/* Remove the qTD from the list by updating the forward pointer to skip
* around this qTD. We do not change that pointer because are repeatedly
* removing the aTD at the head of the QH list.
@@ -577,7 +577,7 @@ static int usb_ehci_qh_discard(struct usb_ehci_qh_s *qh)
int ret;
aicos_dcache_clean_invalid_range((void *)&qh->hw,
sizeof(struct usb_ehci_qh_s));
ROUNDUP(sizeof(struct usb_ehci_qh_s), CACHE_LINE_SIZE));
/* Free all of the qTD's attached to the QH */
ret = usb_ehci_qtd_foreach(qh, usb_ehci_qtd_discard, NULL);
@@ -832,10 +832,16 @@ static int usb_ehci_wait_usbsts(int id, u32 maskbits, u32 donebits, u32 timeout)
int usbh_portchange_wait(int id)
{
u32 usbsts, pending, regval;
u32 usbsts, pending, regval, timeout;
u64 start_us;
volatile struct ehci_hcor_s *hcor;
#ifdef AICUPG_UDISK_VERSION3_SUPPORT
timeout = 150000; // Some Udisk need to wait for more than 1s
#else
timeout = 1000;
#endif
hcor = (struct ehci_hcor_s *)USB_EHCI_HCOR_BASE(id);
start_us = aic_get_time_us();
@@ -854,7 +860,7 @@ int usbh_portchange_wait(int id)
pr_warn("Port status changed.\n");
return 0;
}
} while ((aic_get_time_us() - start_us) < 1000);
} while ((aic_get_time_us() - start_us) < timeout);
return -1;
}
@@ -979,7 +985,7 @@ static int usb_ehci_qtd_addbpl(struct usb_ehci_qtd_s *qtd, const void *buffer,
{
u32 physaddr, nbytes, next, ndx;
aicos_dcache_clean_invalid_range((void *)buffer, buflen);
aicos_dcache_clean_invalid_range((void *)buffer, ROUNDUP(buflen, CACHE_LINE_SIZE));
physaddr = (u32)(uintptr_t)buffer;
for (ndx = 0; ndx < 5; ndx++) {
/* Write the physical address of the buffer into the qTD buffer
@@ -1177,7 +1183,7 @@ static int usb_ehci_qtd_flush(struct usb_ehci_qtd_s *qtd, u32 **bp, void *arg)
*/
aicos_dcache_clean_invalid_range((void *)(uintptr_t)&qtd->hw,
sizeof(struct ehci_qtd_s));
ROUNDUP(sizeof(struct ehci_qtd_s), CACHE_LINE_SIZE));
return 0;
}
@@ -1189,7 +1195,8 @@ static int usb_ehci_qh_flush(struct usb_ehci_qh_s *qh)
* be reloaded from D-Cache.
*/
aicos_dcache_clean_invalid_range((void *)(uintptr_t)&qh->hw, sizeof(struct ehci_qh_s));
aicos_dcache_clean_invalid_range((void *)(uintptr_t)&qh->hw,
ROUNDUP(sizeof(struct ehci_qh_s), CACHE_LINE_SIZE));
/* Then flush all of the qTD entries in the queue */
@@ -1220,7 +1227,8 @@ static void usb_ehci_qh_enqueue(struct usb_ehci_qh_s *qhead,
physaddr = (u32)(uintptr_t)qh;
qhead->hw.hlp = (physaddr | QH_HLP_TYP_QH);
aicos_dcache_clean_range((void *)(uintptr_t)&qhead->hw, sizeof(struct ehci_qh_s));
aicos_dcache_clean_range((void *)(uintptr_t)&qhead->hw,
ROUNDUP(sizeof(struct ehci_qh_s), CACHE_LINE_SIZE));
}
static int usb_ehci_ioc_setup(struct usb_ehci_epinfo_s *epinfo)
@@ -1245,7 +1253,7 @@ static int usb_ehci_qtd_ioccheck(struct usb_ehci_qtd_s *qtd, u32 **bp,
struct usb_ehci_epinfo_s *epinfo = (struct usb_ehci_epinfo_s *)arg;
aicos_dcache_invalid_range((void *)(uintptr_t)&qtd->hw,
sizeof(struct usb_ehci_qtd_s));
ROUNDUP(sizeof(struct usb_ehci_qtd_s), CACHE_LINE_SIZE));
/* Remove the qTD from the list
*
* NOTE that we don't check if the qTD is active nor do we check if there
@@ -1278,7 +1286,8 @@ static int usb_ehci_qh_ioccheck(struct usb_ehci_qh_s *qh, u32 **bp, void *arg)
u32 token;
int ret;
aicos_dcache_invalid_range((void *)(uintptr_t)&qh->hw, sizeof(struct ehci_qh_s));
aicos_dcache_invalid_range((void *)(uintptr_t)&qh->hw,
ROUNDUP(sizeof(struct ehci_qh_s), CACHE_LINE_SIZE));
/* Get the endpoint info pointer from the extended QH data. Only the
* g_asynchead QH can have a NULL epinfo field.
*/
@@ -1322,7 +1331,8 @@ static int usb_ehci_qh_ioccheck(struct usb_ehci_qh_s *qh, u32 **bp, void *arg)
*/
*bp = &qh->hw.hlp;
aicos_dcache_clean_range((void *)(uintptr_t)bp, sizeof(uint32_t));
aicos_dcache_clean_range((void *)(uintptr_t)bp,
ROUNDUP(sizeof(uint32_t), CACHE_LINE_SIZE));
return 0;
}