Hello,
If the charger does have Dp/Dm connected in the plug but the detection happened before the Dp/Dm pins make contact, then it is sufficient to delay the detection.
i.e. when VBUS is detected, wait ~100 ms before calling the imx7d_charger_primary_detection() routine, to allow for signals to settle. (or put a delay in the detection routine).
Redetection afterwards is more difficult because the enumeration may have started. Enumeration will start when the device enables the 1.5K Dp pull-up resistor in the phy and this happens automatically when the controller is started (USB_CMD.RS bit is set).
If the charger detector is enabled whilst the controller is running, the communication with the host will be distorted and the charger detection may return incorrect results.
Hope it helps!
BR,
Ivan.