Minor code tweaks - no functional change.

This commit is contained in:
Martin Whitaker 2022-01-23 17:55:57 +00:00
parent 563c8a1ee7
commit 8509e3320a
2 changed files with 8 additions and 9 deletions

View File

@ -21,7 +21,7 @@
// Values defined by the OHCI specification. // Values defined by the OHCI specification.
// HcRevision register // HcControl register
#define OHCI_CTRL_CBSR 0x00000003 // Control Bulk Service Ratio #define OHCI_CTRL_CBSR 0x00000003 // Control Bulk Service Ratio
#define OHCI_CTRL_CBSR0 0x00000000 // Control Bulk Service Ratio 0 #define OHCI_CTRL_CBSR0 0x00000000 // Control Bulk Service Ratio 0
@ -592,7 +592,7 @@ bool ohci_init(uintptr_t base_addr, usb_hcd_t *hcd)
// Initialise the interrupt ED and TD for each keyboard interface and find the minimum interval. // Initialise the interrupt ED and TD for each keyboard interface and find the minimum interval.
int min_interval = OHCI_MAX_INTERVAL; int min_interval = OHCI_MAX_INTERVAL;
ohci_ed_t *last_kbd_ed = NULL; uint32_t intr_head_ed = 0;
for (int kbd_idx = 0; kbd_idx < num_keyboards; kbd_idx++) { for (int kbd_idx = 0; kbd_idx < num_keyboards; kbd_idx++) {
usb_ep_t *kbd = &keyboards[kbd_idx]; usb_ep_t *kbd = &keyboards[kbd_idx];
@ -604,8 +604,8 @@ bool ohci_init(uintptr_t base_addr, usb_hcd_t *hcd)
build_ohci_td(kbd_td, OHCI_TD_DP_IN | OHCI_TD_DT_USE_TD | OHCI_TD_DT_0 | OHCI_TD_DI_NO_DLY, kbd_rpt, sizeof(hid_kbd_rpt_t)); build_ohci_td(kbd_td, OHCI_TD_DP_IN | OHCI_TD_DT_USE_TD | OHCI_TD_DT_0 | OHCI_TD_DI_NO_DLY, kbd_rpt, sizeof(hid_kbd_rpt_t));
build_ohci_ed(kbd_ed, ohci_ed_control(kbd), kbd_td+0, kbd_td+1); build_ohci_ed(kbd_ed, ohci_ed_control(kbd), kbd_td+0, kbd_td+1);
kbd_ed->next_ed = (uintptr_t)last_kbd_ed; kbd_ed->next_ed = intr_head_ed;
last_kbd_ed = kbd_ed; intr_head_ed = (uintptr_t)kbd_ed;
if (kbd->interval < min_interval) { if (kbd->interval < min_interval) {
min_interval = kbd->interval; min_interval = kbd->interval;
@ -614,7 +614,7 @@ bool ohci_init(uintptr_t base_addr, usb_hcd_t *hcd)
// Initialise the interrupt table. // Initialise the interrupt table.
for (int i = 0; i < OHCI_MAX_INTERVAL; i += min_interval) { for (int i = 0; i < OHCI_MAX_INTERVAL; i += min_interval) {
ws->hcca.intr_head_ed[i] = (uintptr_t)last_kbd_ed; ws->hcca.intr_head_ed[i] = intr_head_ed;
} }
write32(&op_regs->control, OHCI_CTRL_HCFS_RUN | OHCI_CTRL_CLE | OHCI_CTRL_PLE | OHCI_CTRL_CBSR0); write32(&op_regs->control, OHCI_CTRL_HCFS_RUN | OHCI_CTRL_CLE | OHCI_CTRL_PLE | OHCI_CTRL_CBSR0);
flush32(&op_regs->interrupt_status, ~0); flush32(&op_regs->interrupt_status, ~0);

View File

@ -102,8 +102,7 @@
// Add Context flags // Add Context flags
#define XHCI_CONTEXT_A0 (1 << 0) #define XHCI_CONTEXT_A(n) (1 << (n))
#define XHCI_CONTEXT_A1 (1 << 1)
// Port Speed values // Port Speed values
@ -737,7 +736,7 @@ static bool assign_address(const usb_hcd_t *hcd, const usb_hub_t *hub, int port_
// Prepare the input context for the ADDRESS_DEVICE command. // Prepare the input context for the ADDRESS_DEVICE command.
xhci_ctrl_context_t *ctrl_context = (xhci_ctrl_context_t *)ws->input_context_addr; xhci_ctrl_context_t *ctrl_context = (xhci_ctrl_context_t *)ws->input_context_addr;
ctrl_context->add_context_flags = XHCI_CONTEXT_A0 | XHCI_CONTEXT_A1; ctrl_context->add_context_flags = XHCI_CONTEXT_A(0) | XHCI_CONTEXT_A(1);
xhci_slot_context_t *slot_context = (xhci_slot_context_t *)(ws->input_context_addr + ws->context_size); xhci_slot_context_t *slot_context = (xhci_slot_context_t *)(ws->input_context_addr + ws->context_size);
slot_context->params1 = 1 << 27 | usb_to_xhci_speed(device_speed) << 20; slot_context->params1 = 1 << 27 | usb_to_xhci_speed(device_speed) << 20;
@ -828,7 +827,7 @@ static bool configure_interrupt_endpoint(workspace_t *ws, const usb_ep_t *ep, in
// CONFIGURE_ENDPOINT command before issuing the command. // CONFIGURE_ENDPOINT command before issuing the command.
xhci_ctrl_context_t *ctrl_context = (xhci_ctrl_context_t *)ws->input_context_addr; xhci_ctrl_context_t *ctrl_context = (xhci_ctrl_context_t *)ws->input_context_addr;
ctrl_context->add_context_flags = XHCI_CONTEXT_A0 | 1 << ep_id; ctrl_context->add_context_flags = XHCI_CONTEXT_A(0) | XHCI_CONTEXT_A(ep_id);
xhci_slot_context_t *slot_context = (xhci_slot_context_t *)(ws->input_context_addr + ws->context_size); xhci_slot_context_t *slot_context = (xhci_slot_context_t *)(ws->input_context_addr + ws->context_size);
slot_context->params1 = ep_id << 27 | hub_flag << 26 | (slot_context->params1 & 0x00ffffff); slot_context->params1 = ep_id << 27 | hub_flag << 26 | (slot_context->params1 & 0x00ffffff);