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:

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?