I am setting up a USB device tree that switches between Host & Device mode but mode selection is not driven by GPIO pin but rather software (on boot it should be Device but later would switch to Host). Is there a clear example or application note that covers this?
I don’t think what you are talking about is able to be achieved. The kernel side chooses the role of usb to be host and device mode by the vbus and id pins. Thus, it is totally GPIO/hardware.
Some hack might be able to change the role but we don’t suggest that without correct hardware design.