Contribute
Register

USB-C Hotplug Questions

Status
Not open for further replies.
Ok, so one interesting thing to note, I had assumed that IOUSBFamily would have power properties for MBP14,1 but it turns out that it doesn't. So after implementing a USBX ssdt, I was no longer able to hot plug USB-C. Remove USBX, hot plugging worked again. :-/
 
Ok, so one interesting thing to note, I had assumed that IOUSBFamily would have power properties for MBP14,1 but it turns out that it doesn't.

Yeah, not expected. Apple is using USBX for new computers. IOUSBHostFamily injects for legacy.

So after implementing a USBX ssdt, I was no longer able to hot plug USB-C. Remove USBX, hot plugging worked again. :-/

Curious.
 
Ok, so one interesting thing to note, I had assumed that IOUSBFamily would have power properties for MBP14,1 but it turns out that it doesn't. So after implementing a USBX ssdt, I was no longer able to hot plug USB-C. Remove USBX, hot plugging worked again. :-/
Hi jhax01,
I had read your

[Guide] HP Elite X2 1012...
What about your new Elite x2 G2? Does everything work?
What about new differences between old generation?
I want to be sure before buying the new G2... ;-)
 
Hi jhax01,
I had read your

[Guide] HP Elite X2 1012...
What about your new Elite x2 G2? Does everything work?
What about new differences between old generation?
I want to be sure before buying the new G2... ;-)

No, not everything works...You'll struggle to find a hack where everything works perfectly. On the G2, the cameras don't work and won't unless someone writes a PCI driver for them. I've considered making the attempt, but I can count the times on one hand that I used the camera on the G1, so.... The SD card can be made to work, but isn't really reliable at this point. As you can see in this thread, USB-C is hot pluggable. I can't confirm whether or not TB3 works/is hot pluggable because I don't own any devices. I've used USB-C storage, USB-A adapters, and an HDMI adapter on the USB-C/TB3 port with success. The HDMI adapter even was able to drive a 1440p monitor @ 144hz. The pen works fine, but there is no pressure sensitivity on Sierra (works fine on El Cap). You can see a demo of the operation here -------------------

Bear in mind that the above is using a customized driver incorporating gesture processing by UPDD and singletouch/pen processing by a pre-release version of VoodooI2C. We now have GPIO interrupts working in VoodooI2C so idle usage is nil which is very helpful for battery life vs 1.0. Once the VoodooI2C rewrite is complete, I'll be able to write a satellite kext that will incorporate some basic swipe gestures without UPDD (which costs around $110 unfortunately). Otherwise, I'm very happy with the device as both a hack and a Windows machine. Hope that helps. If you have any other questions, best to just reply to one of the G1 install threads.
 
No, not everything works...You'll struggle to find a hack where everything works perfectly. On the G2, the cameras don't work and won't unless someone writes a PCI driver for them. I've considered making the attempt, but I can count the times on one hand that I used the camera on the G1, so.... The SD card can be made to work, but isn't really reliable at this point. As you can see in this thread, USB-C is hot pluggable. I can't confirm whether or not TB3 works/is hot pluggable because I don't own any devices. I've used USB-C storage, USB-A adapters, and an HDMI adapter on the USB-C/TB3 port with success. The HDMI adapter even was able to drive a 1440p monitor @ 144hz. The pen works fine, but there is no pressure sensitivity on Sierra (works fine on El Cap). You can see a demo of the operation here -------------------

Bear in mind that the above is using a customized driver incorporating gesture processing by UPDD and singletouch/pen processing by a pre-release version of VoodooI2C. We now have GPIO interrupts working in VoodooI2C so idle usage is nil which is very helpful for battery life vs 1.0. Once the VoodooI2C rewrite is complete, I'll be able to write a satellite kext that will incorporate some basic swipe gestures without UPDD (which costs around $110 unfortunately). Otherwise, I'm very happy with the device as both a hack and a Windows machine. Hope that helps. If you have any other questions, best to just reply to one of the G1 install threads.
Thanks for the very clear answer. Given the current incompleteness and the cost I think to buying a used G1 for now and following your tips and tricks from the main thread !! Nice.. Great job, man!
 
Does a real Mac show the "express card icon" for TB devices?
They don't. We're using this trick because laptops like the Dell XPSes power down (completely) their Type-C port controllers when nothing's using them, and an ExpressCard is a device that also behaves like this. Per dpassmor's descriptions, USB controller ExpressCard devices are real, and Mac OS has support for them, which is why this even works for any of us with power-down ports at all.

The icon appears when a USB/TB device is plugged in because the OS is responding to the port powering up in accordance with how we've specifically told it to respond. You could use the icon to force power off the port, but that would make USB devices get "surprised unplugged." Doing so will also prevent the port from working again that session, hence why it's best to ignore the icon. The icon also crashes the menu bar if you try to click it when a Thunderbolt device is plugged in. Again, this is all just a byproduct of the trick we need to use for controllers that get powered off like the Dell XPS one, and none of this is how actual Macs do anything. Actual Macs use a driver and (I think) an always-on port. I'm not 100% sure on the latter, since I only have TB2 Macs that appear to have an always-on port. Note: By "always-on" I mean "always has a big tree in the IOService part of IOReg with a lot of Thunderbolt-related things hanging off it," so there very well might be something else at play I'm missing.

One thing that may additionally be worth considering with regard to these "power-down ports" is that Windows has no problem with devices appearing and disappearing, as long as there is something there to handle that behavior. The ExpressCard trick indicates that Mac OS behaves the same way (the ExpressCard support being the existing subsystem that can handle the removable PCIe device we've provided the OS), which means that a custom Type-C driver (kext) to handle the specific parts of Type-C that Apple's existing drivers can't handle would probably solve everything for everybody without relying on niche behavior. And it turns out Linux can handle all of this already, so it should just be a matter of porting the minimum necessary bits--just whatever's necessary to get Apple's drivers to take over and then to take care of any removal cleanup that Apple's drivers can't do.

Either way, reverse engineering IOPCIFamily.kext, AppleThunderboltNHI.kext, and IOThunderboltFamily.kext is necessary to understand what's going on on the TB side of things, and I don't think that's been done particularly thoroughly yet. On the USB side of things, well, I'm not totally sure which kexts handle the Type-C USB stuff.

Btw, I totally just hot-plugged [in] a TB device and it's working, but Mac OS has no idea it's a Thunderbolt thing.

System Profiler:
Thunderbolt: No drivers are loaded.
 

Attachments

  • Screen Shot 2017-09-08 at 23.23.17.png
    Screen Shot 2017-09-08 at 23.23.17.png
    178 KB · Views: 258
They don't. We're using this trick because laptops like the Dell XPSes power down (completely) their Type-C port controllers when nothing's using them, and an ExpressCard is a device that also behaves like this.

That's what I thought...
Probably best way would be to find a way to disable the hotplug nature of the TB controller, so it is more like Apple's hardware.

Per dpassmor's descriptions, USB controller ExpressCard devices are real, and Mac OS has support for them, which is why this even works for any of us with power-down ports at all.

It is fine for a work around, but will probably never be 100%.
 
@jaymonkey I also have an HP Spectre the x360 Kaby Lake 13 inch i5. Using a combination of your SSDT patch and Rehabman's suggestion to define the ACPI devices, I came up with the following SSDT:

Code:
DefinitionBlock("", "SSDT", 2, "hack", "TYPC", 0)
{
    External(_SB.PCI0.RP05.PXSX, DeviceObj)
        External (_SB.TBTS,FieldUnitObj)
    External (_SB.PCI0.RP05.SBNR,FieldUnitObj)
    External (_SB.TBUS,IntObj)
    Scope(_SB.PCI0.RP05.PXSX)
    {
        Method (_RMV, 0, NotSerialized)  // _RMV: Removal Status
        {
            Return(One)
        }
        Device(EP00) { Name(_ADR, 0) }
        Device(EP01) { Name(_ADR, 0x00010000) }
        Device(EP02)
        {
            Name(_ADR, 0x00020000)
            Device (NHI0)
            {
                Name (_ADR, Zero)  // _ADR: Address
                Name (_STR, Unicode ("Thunderbolt"))  // _STR: Description String
                Method (_RMV, 0, NotSerialized)  // _RMV: Removal Status
                {
                    Return (One)
                }

                Method (_DSM, 4, NotSerialized)  // _DSM: Device-Specific Method
                {
                    If (LNot (Arg2))
                    {
                        Return (Buffer (One)
                        {
                             0x03                                          
                        })
                    }

                    Store (Package (0x03)
                        {
                            "power-save",
                            One,
                            Buffer (One)
                            {
                                 0x00                                          
                            }
                        }, Local0)
                    Return (Local0)
                }
        }
    }
}
}

Note I use hot patching, for your config the _RMV method obviously must be replaced in the DSDT. I have bios revision F40, and my controller works on hotplug, even after sleep/wake. I still have the "USB Controller" Menu item, although that may be due to my test device (USB C adapter dock) having a usb type A port. Notably, I do not select "Power off Card" when removing my device, as that appears to fully power down the bus and result in hotplug no longer working.
 
@jaymonkey I also have an HP Spectre the x360 Kaby Lake 13 inch i5. Using a combination of your SSDT patch and Rehabman's suggestion to define the ACPI devices, I came up with the following SSDT:

@ddegrasse,

interesting development ..... i tried your DSDT but it didn't work any better for me .... Still need to have device attached at boot up and can not hot plug usb type C (on TB port) so can only use once ....

However, as before I can still hot swap a usb type A device if i keep the Type C to Type A adapter in the TB/USB C port, so it still looks like the port power is removed once usb type C connector is removed ... only difference is that the icon stays in the menu with your SSDT where as it disappears using my code .. ?

How did you deal with the _RMV method in your DSDT for RP05,PXSX .. did you keep the conditional code or modify so that the method always returned one regardless ?, for me it made no difference either way.

I checked my dsdt has the same external names (TBTS, SBNR, TBUS ..etc) which it does

That all said i'm on BIOS version F.20 so will look into that ...

Cheers
Jay

Update-1: I just checked the HP support site and a new BIOS (F.30 rev A) was released in Nov 2017 for 15" Spectre X360 Kaby lake, details on the update only state that it provides support for Microsoft Windows 10 v1709 .... but might be worth a try.

Update-2: Installed latest BIOS (F.30 Rev A) for 15" KBL Spectre X360 but as I suspected it did not help .... TB/USB-C port behaviour is the same as it was with F.20 .... Must be some differences in the TB hardware between the 13" and 15" models.
 
Last edited:
@ddegrasse,

interesting development ..... i tried your DSDT but it didn't work any better for me .... Still need to have device attached at boot up and can not hot plug usb type C (on TB port) so can only use once ....

However, as before I can still hot swap a usb type A device if i keep the Type C to Type A adapter in the TB/USB C port, so it still looks like the port power is removed once usb type C connector is removed ... only difference is that the icon stays in the menu with your SSDT where as it disappears using my code .. ?

How did you deal with the _RMV method in your DSDT for RP05,PXSX .. did you keep the conditional code or modify so that the method always returned one regardless ?, for me it made no difference either way.

I checked my dsdt has the same external names (TBTS, SBNR, TBUS ..etc) which it does

That all said i'm on BIOS version F.20 so will look into that ...

Cheers
Jay

Update-1: I just checked the HP support site and a new BIOS (F.30 rev A) was released in Nov 2017 for 15" Spectre X360 Kaby lake, details on the update only state that it provides support for Microsoft Windows 10 v1709 .... but might be worth a try.

Update-2: Installed latest BIOS (F.30 Rev A) for 15" KBL Spectre X360 but as I suspected it did not help .... TB/USB-C port behaviour is the same as it was with F.20 .... Must be some differences in the TB hardware between the 13" and 15" models.
Interesting, on my HP the latest UEFI update is F.40, the full model name is HP Spectre 13-ac000 x360. Weirdly, each update to the firmware actually seems to have improved compatibility with OSX. It may indeed be the case that our devices have different implementations.

As far as the _RMV method, I returned one at all times.
 
Status
Not open for further replies.
Back
Top