From 857b3e92f8b81f36c3513642e8dbcefedc2e1447 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 21 Nov 2024 13:40:16 +0200 Subject: [PATCH] Kernel: Support initializing USB 3 devices --- kernel/kernel/USB/XHCI/Controller.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/kernel/kernel/USB/XHCI/Controller.cpp b/kernel/kernel/USB/XHCI/Controller.cpp index f8309c14ff..cc801133f7 100644 --- a/kernel/kernel/USB/XHCI/Controller.cpp +++ b/kernel/kernel/USB/XHCI/Controller.cpp @@ -268,6 +268,7 @@ namespace Kernel // read and clear needed change flags const bool reset_change = op_port.portsc & XHCI::PORTSC::PRC; const bool connection_change = op_port.portsc & XHCI::PORTSC::CSC; + const bool port_enabled = op_port.portsc & XHCI::PORTSC::PED; op_port.portsc = XHCI::PORTSC::CSC | XHCI::PORTSC::PRC | XHCI::PORTSC::PP; if (!(op_port.portsc & XHCI::PORTSC::CCS)) @@ -284,18 +285,18 @@ namespace Kernel switch (my_port.revision_major) { case 2: - if (!reset_change) - { - if (connection_change) - op_port.portsc = XHCI::PORTSC::PR | XHCI::PORTSC::PP; - continue; - } - break; - case 3: - if (!connection_change) - continue; - dprintln_if(DEBUG_XHCI, "USB 3 devices not supported"); + // USB2 ports advance to Enabled state after a reset + if (port_enabled && reset_change) + break; + // reset port + if (connection_change) + op_port.portsc = XHCI::PORTSC::PR | XHCI::PORTSC::PP; continue; + case 3: + if (!connection_change || !port_enabled) + continue; + // USB3 ports advance to Enabled state automatically + break; default: continue; }