Changeset c8bb7090 in mainline
- Timestamp:
- 2017-07-16T17:24:42Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37789b5f
- Parents:
- fe5db713
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/Makefile
rfe5db713 rc8bb7090 47 47 scratchpad.c \ 48 48 commands.c \ 49 49 rh.c \ 50 50 main.c 51 51 -
uspace/drv/bus/usb/xhci/rh.c
rfe5db713 rc8bb7090 39 39 #include "debug.h" 40 40 #include "hc.h" 41 #include "hw_struct/trb.h" 41 42 #include "rh.h" 42 43 43 #include "hw_struct/trb.h" 44 static int handle_connected_device(xhci_hc_t* hc, xhci_port_regs_t* regs, uint8_t port_id) 45 { 46 uint8_t link_state = XHCI_REG_RD(regs, XHCI_PORT_PLS); 47 if (link_state == 0) { 48 // USB3 is automatically advance to enabled 49 uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS); 50 usb_log_debug2("Detected new device on port %u, port speed id %u.", port_id, port_speed); 51 // TODO: Assign device slot (specification 4.3.2) 52 } else if (link_state == 5) { 53 // USB 3 failed to enable 54 usb_log_debug("USB 3 port couldn't be enabled."); 55 } else if (link_state == 7) { 56 usb_log_debug("USB 2 device attached, issuing reset."); 57 xhci_reset_hub_port(hc, port_id); 58 } 44 59 45 static int handle_connected_device(xhci_hc_t* hc, xhci_port_regs_t* regs, uint8_t port_id) { 46 uint8_t link_state = XHCI_REG_RD(regs, XHCI_PORT_PLS); 47 if(link_state == 0) { 48 // USB3 is automatically advance to enabled 49 uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS); 50 usb_log_debug2("Detected new device on port %u, port speed id %u.", port_id, port_speed); 51 // TODO: Assign device slot (specification 4.3.2) 52 } 53 else if(link_state == 5) { 54 // USB 3 failed to enable 55 usb_log_debug("USB 3 port couldn't be enabled."); 56 } 57 else if(link_state == 7) { 58 usb_log_debug("USB 2 device attached, issuing reset."); 59 xhci_reset_hub_port(hc, port_id); 60 } 61 62 return EOK; 60 return EOK; 63 61 } 64 62 65 int xhci_handle_port_status_change_event(xhci_hc_t *hc, xhci_trb_t *trb) { 66 uint8_t port_id = xhci_get_hub_port(trb); 67 usb_log_debug("Port status change event detected for port %u.", port_id); 68 xhci_port_regs_t* regs = &hc->op_regs->portrs[port_id]; 63 int xhci_handle_port_status_change_event(xhci_hc_t *hc, xhci_trb_t *trb) 64 { 65 uint8_t port_id = xhci_get_hub_port(trb); 66 usb_log_debug("Port status change event detected for port %u.", port_id); 67 xhci_port_regs_t* regs = &hc->op_regs->portrs[port_id]; 69 68 70 71 if(XHCI_REG_RD(regs, XHCI_PORT_PRC)) {72 73 69 // Port reset change 70 if (XHCI_REG_RD(regs, XHCI_PORT_PRC)) { 71 // Clear the flag 72 XHCI_REG_WR(regs, XHCI_PORT_PRC, 1); 74 73 75 76 77 78 74 uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS); 75 usb_log_debug2("Detected port reset on port %u, port speed id %u.", port_id, port_speed); 76 // TODO: Assign device slot (specification 4.3.2) 77 } 79 78 80 81 if(XHCI_REG_RD(regs, XHCI_PORT_CSC)) {82 79 // Connection status change 80 if (XHCI_REG_RD(regs, XHCI_PORT_CSC)) { 81 XHCI_REG_WR(regs, XHCI_PORT_CSC, 1); 83 82 84 if(XHCI_REG_RD(regs, XHCI_PORT_CCS) == 1) {85 86 } 87 else { 88 // Device disconnected 89 90 } 91 83 if (XHCI_REG_RD(regs, XHCI_PORT_CCS) == 1) { 84 handle_connected_device(hc, regs, port_id); 85 } else { 86 // Device disconnected 87 } 88 } 89 90 return EOK; 92 91 } 93 92 94 int xhci_get_hub_port(xhci_trb_t *trb) { 95 assert(trb); 96 uint8_t port_id = XHCI_QWORD_EXTRACT(trb->parameter, 63, 56); 97 return port_id; 93 int xhci_get_hub_port(xhci_trb_t *trb) 94 { 95 assert(trb); 96 uint8_t port_id = XHCI_QWORD_EXTRACT(trb->parameter, 63, 56); 97 98 return port_id; 98 99 } 99 100 100 int xhci_reset_hub_port(xhci_hc_t* hc, uint8_t port) { 101 usb_log_debug2("Resetting port %u.", port); 102 xhci_port_regs_t regs = hc->op_regs->portrs[port]; 103 XHCI_REG_WR(®s, XHCI_PORT_PR, 1); 104 return EOK; 101 int xhci_reset_hub_port(xhci_hc_t* hc, uint8_t port) 102 { 103 usb_log_debug2("Resetting port %u.", port); 104 xhci_port_regs_t regs = hc->op_regs->portrs[port]; 105 XHCI_REG_WR(®s, XHCI_PORT_PR, 1); 106 107 return EOK; 105 108 } 106 109 110 111 /** 112 * @} 113 */ -
uspace/drv/bus/usb/xhci/rh.h
rfe5db713 rc8bb7090 42 42 43 43 #endif 44 45 /** 46 * @} 47 */
Note:
See TracChangeset
for help on using the changeset viewer.