Implanting xhci_run and some free functions

This commit is contained in:
xj 2024-07-29 04:49:30 -07:00
parent bed67b388f
commit f322fce778
1 changed files with 27 additions and 16 deletions

View File

@ -1050,21 +1050,28 @@ static void xhci_run ( struct xhci_host *xhci ) {
uint32_t runtime;
/* Configure number of device slots */
config = readl ( xhci->op + XHCI_OP_CONFIG );
// config = readl ( xhci->op + XHCI_OP_CONFIG );
config = readl ( xhci->op_addr + XHCI_OP_CONFIG );
config &= ~XHCI_CONFIG_MAX_SLOTS_EN_MASK;
config |= XHCI_CONFIG_MAX_SLOTS_EN ( xhci->slots );
writel ( config, xhci->op + XHCI_OP_CONFIG );
// writel ( config, xhci->op + XHCI_OP_CONFIG );
writel ( config, xhci->op_addr + XHCI_OP_CONFIG );
/* Enable port interrupt */
writel ( 500U, xhci->run + XHCI_RUN_IR_IMOD ( 0 ) );
runtime = readl(xhci->run + XHCI_RUN_IR_IMAN ( 0 ));
// writel ( 500U, xhci->run + XHCI_RUN_IR_IMOD ( 0 ) );
writel ( 500U, xhci->run_addr + XHCI_RUN_IR_IMOD ( 0 ) );
// runtime = readl(xhci->run + XHCI_RUN_IR_IMAN ( 0 ));
runtime = readl(xhci->run_addr + XHCI_RUN_IR_IMAN ( 0 ));
runtime |= XHCI_RUN_IR_IMAN_IE;
writel (runtime, xhci->run + XHCI_RUN_IR_IMAN ( 0 ));
// writel (runtime, xhci->run + XHCI_RUN_IR_IMAN ( 0 ));
writel (runtime, xhci->run_addr + XHCI_RUN_IR_IMAN ( 0 ));
/* Set run/stop bit and enable interrupt */
usbcmd = readl ( xhci->op + XHCI_OP_USBCMD );
// usbcmd = readl ( xhci->op + XHCI_OP_USBCMD );
usbcmd = readl ( xhci->op_addr + XHCI_OP_USBCMD );
usbcmd |= XHCI_USBCMD_RUN | XHCI_USBCMD_INTE;
writel ( usbcmd, xhci->op + XHCI_OP_USBCMD );
// writel ( usbcmd, xhci->op + XHCI_OP_USBCMD );
writel ( usbcmd, xhci->op_addr + XHCI_OP_USBCMD );
USB_LOG_DBG("XHCI %s start running\n", xhci->name );
}
@ -1077,15 +1084,18 @@ static void xhci_run ( struct xhci_host *xhci ) {
static void xhci_event_free ( struct xhci_host *xhci ) {
/* Clear event ring registers */
writel ( 0, xhci->run + XHCI_RUN_ERSTSZ ( 0 ) );
xhci_writeq ( xhci, 0, xhci->run + XHCI_RUN_ERSTBA ( 0 ) );
xhci_writeq ( xhci, 0, xhci->run + XHCI_RUN_ERDP ( 0 ) );
// writel ( 0, xhci->run + XHCI_RUN_ERSTSZ ( 0 ) );
writel ( 0, xhci->run_addr + XHCI_RUN_ERSTSZ ( 0 ) );
// xhci_writeq ( xhci, 0, xhci->run + XHCI_RUN_ERSTBA ( 0 ) );
xhci_writeq ( xhci, 0, xhci->run_addr + XHCI_RUN_ERSTBA ( 0 ) );
// xhci_writeq ( xhci, 0, xhci->run + XHCI_RUN_ERDP ( 0 ) );
xhci_writeq ( xhci, 0, xhci->run_addr + XHCI_RUN_ERDP ( 0 ) );
/* Free event ring segment table */
usb_free ( xhci->eseg );
// usb_free ( xhci->eseg );
/* Free event ring */
usb_free ( xhci->evts );
// usb_free ( xhci->evts );
}
/**
@ -1099,10 +1109,11 @@ static void xhci_command_free ( struct xhci_host *xhci ) {
USB_ASSERT ( ( readl ( xhci->op + XHCI_OP_CRCR ) & XHCI_CRCR_CRR ) == 0 );
/* Clear command ring control register */
xhci_writeq ( xhci, 0, xhci->op + XHCI_OP_CRCR );
// xhci_writeq ( xhci, 0, xhci->op + XHCI_OP_CRCR );
xhci_writeq ( xhci, 0, xhci->op_addr + XHCI_OP_CRCR );
/* Free TRB ring */
usb_free ( xhci->cmds );
// usb_free ( xhci->cmds );
}
/**
@ -1125,11 +1136,11 @@ static void xhci_scratchpad_free ( struct xhci_host *xhci ) {
/* Free scratchpad array */
array_len = ( scratch->count * sizeof ( scratch->array[0] ) );
usb_free ( scratch->array );
// usb_free ( scratch->array );
/* Free scratchpad buffers */
buffer_len = ( scratch->count * xhci->pagesize );
usb_free ( scratch->buffer );
// usb_free ( scratch->buffer );
}
/**