Skip to content

Creating a Custom SSDT for USB Ports

fidele007 edited this page Dec 31, 2018 · 3 revisions

This guide details how I created the SSDT patch for USB ports by following the RehabMan's guide.

In order to create the patch, first we need to know what ports to enable, and we can do with the help of USBInjectAll.kext. Any existing SSDT patch for the ports can be disabled with the -uia_ignore_rmcf flag in the boot arguments.

With IORegistryExplorer, search for XHC to see all the unlocked ports. Plug and unplug devices into the USB ports to see which port correspond to which on your computer. As for the ASUS ROG GL552VW, I've detected the following ports:

  • HS01: USB2 device on a USB3 port (left side - #1 from the USB-C port), port <01 00 00 00>
  • HS02: USB-C Port, port <02 00 00 00>
  • HS04: USB 2.0 UVC HD Webcam, port <04 00 00 00>
  • HS05: USB2 device on a USB3 port, port <05 00 00 00>
  • HS06: USB2/USB3 device on a USB2 port (right side), port <06 00 00 00>
  • HS09: Bluetooth, port <09 00 00 00>
  • SS01: USB3 port (left side - #1 from the USB-C port), port <11 00 00 00>
  • SS05: USB3 port (left side - #2 from the USB-C port), port <15 00 00 00>

Now that we've identified all the ports to keep, we can start creating our SSDT patch. The patch template can be found here:

// SSDT-UIAC-ALL.dsl
//
// This SSDT can be used as a template to build your own
// customization for USBInjectAll.kext.
//
// This SSDT contains all ports, so using it is the same as without
// a custom SSDT.  Delete ports that are not connected or ports you
// do not need.
//
// Change the UsbConnector or portType as needed to match your
// actual USB configuration.
//
// Note:
// portType=0 seems to indicate normal external USB2 port (as seen in MacBookPro8,1)
// portType=2 seems to indicate "internal device" (as seen in MacBookPro8,1)
// portType=4 is used by MacBookPro8,3 (reason/purpose unknown)
//

DefinitionBlock ("", "SSDT", 2, "hack", "_UIAC", 0)
{
    Device(UIAC)
    {
        Name(_HID, "UIA00000")

        Name(RMCF, Package()
        {
            "HUB1", Package()
            {
                "port-count", Buffer() { 8, 0, 0, 0 },
                "ports", Package()
                {
                    "HP11", Package()
                    {
                        //"UsbConnector", 0,
                        "portType", 0,
                        "port", Buffer() { 1, 0, 0, 0 },
                    },
                    "HP12", Package()
                    {
                        //"UsbConnector", 0,
                        "portType", 0,
                        "port", Buffer() { 2, 0, 0, 0 },
                    },
                    "HP13", Package()
                    {
                        //"UsbConnector", 0,
                        "portType", 0,
                        "port", Buffer() { 3, 0, 0, 0 },
                    },
                    "HP14", Package()
                    {
                        //"UsbConnector", 0,
                        "portType", 0,
                        "port", Buffer() { 4, 0, 0, 0 },
                    },
                    "HP15", Package()
                    {
                        //"UsbConnector", 0,
                        "portType", 0,
                        "port", Buffer() { 5, 0, 0, 0 },
                    },
                    "HP16", Package()
                    {
                        //"UsbConnector", 0,
                        "portType", 0,
                        "port", Buffer() { 6, 0, 0, 0 },
                    },
                    "HP17", Package()
                    {
                        //"UsbConnector", 0,
                        "portType", 0,
                        "port", Buffer() { 7, 0, 0, 0 },
                    },
                    "HP18", Package()
                    {
                        //"UsbConnector", 0,
                        "portType", 0,
                        "port", Buffer() { 8, 0, 0, 0 },
                    },
                },
            },
            ...
        })
    }
}
//EOF

We do not need all the configurations. The device-id of the ASUS ROG GL552VW board matches with 8086_a12f, so we are going to keep only that configuration. Here are the data mappings:

  • UsbConnector is the connector type: USB2 = 0, USB3 = 3, internal = 255. USB type C ports can be either 9 or 10, which depends on how the hardware deals with the two possible orientations of a USB type C device/cable:
    • If a USB-C uses the same SSxx in both orientations, then it has an internal switch (UsbConnector=9).
    • If a USB-C uses a different SSxx in each orientation, then it has no switch (UsbConnector=10).
  • Take note of the port value in IORegistryExplorer for each connector's port

My resulting SSDT for ASUS ROG GL552VW looks like this:

DefinitionBlock ("SSDT-USB.aml", "SSDT", 1, "sample", "USBFix", 0x00003000)
{
    // "USBInjectAllConfiguration" : override settings for USBInjectAll.kext
    Device(UIAC)
    {
        Name(_HID, "UIA00000")
        // "RehabManConFiguration"
        Name(RMCF, Package()
        {
            // XHC overrides for 100-series boards
            "8086_a12f", Package()
            {
                "port-count", Buffer() { 0x15, 0, 0, 0}, // Highest port number is SS** at 0xNN
                "ports", Package()
                {   // TO COMPLETE THIS FILE, ADD ALL YOUR PORTS BELOW HERE, THEN SET port-count ABOVE
                    
                    "HS01", Package() // USB2 device on a USB3 port (left side - #1 from the USB-C port), port <01 00 00 00>
                    {
                        "UsbConnector", 3,
                        "port", Buffer() { 0x01, 0, 0, 0 },
                    },
                    
                    "HS02", Package() // USB-C Port, port <02 00 00 00>
                    {
                        "UsbConnector", 9,
                        "port", Buffer() { 0x02, 0, 0, 0 },
                    },
                    
                    "HS04", Package() // USB 2.0 UVC HD Webcam, port <04 00 00 00>
                    {
                        "UsbConnector", 255,
                        "port", Buffer() { 0x04, 0, 0, 0 },
                    },
                    
                    "HS05", Package() // USB2 device on a USB3 port (left side - #2 from the USB-C port), port <05 00 00 00>
                    {
                        "UsbConnector", 3,
                        "port", Buffer() { 0x05, 0, 0, 0 },
                    },
                    
                    "HS06", Package() // USB2/USB3 device on a USB2 port (right side), port <06 00 00 00>
                    {
                        "UsbConnector", 0,
                        "port", Buffer() { 0x06, 0, 0, 0 },
                    },
                    
                    "HS09", Package() // Bluetooth
                    {
                        "UsbConnector", 255,
                        "port", Buffer() { 0x09, 0, 0, 0 },
                    },

                    "SS01", Package() // USB3 port (left side - #1 from the USB-C port), port <11 00 00 00>
                    {
                        "UsbConnector", 3,
                        "port", Buffer() { 0x11, 0, 0, 0 },
                    },
                    
                    "SS05", Package() // USB3 port (left side - #2 from the USB-C port), port <15 00 00 00>
                    {
                        "UsbConnector", 3,
                        "port", Buffer() { 0x15, 0, 0, 0 },
                    }
                },
            },
        })
    }
}

Save the SSDT file as aml in CLOVER/ACPI/patched and restart. After restarting, check that only the correct ports are displayed.