Determine where USB configuration takes place

I am trying to determine what kernel sources are involved in setting the USB registers so that I can hack 2 usb hosts like this:

https://pansenti.wordpress.com/2013/07/10/the-horribly-hacked-beaglebone-black-with-dual-usb-host-ports-aka-frankenbone-its-alive/#comment-1677

According to the Technical Reference Manual “The OTG supplement feature, the support for a dynamic role change, is also supported. Each port has the support for a dual-role feature allowing for additional versatility enabling operation capability as a host or peripheral. Both ports have identical capabilities”

I wonder if this means the port can change from device to host after the kernel is booted? If so then that would simplify things as the problem would be reduced to rewiring the board and then reconfiguring the USB in an initialization script.

What is the easiest approach?