Configure the MGTs based on the links
Description
At the moment, cmsgemos
configures and resets the MGTs by looping over the number of MGTs. This is somewhat incorrect due to the fact that not all are MGTs necessarily used. Additionally, the polarity swaps that may be required on a given board are not available at the MGT level.
Instead, the configuration and reset loops must be performed on the links. A link represents an optical fiber, describes to which MGT it is connected, and specifies if polarity swaps are required.
On the other hand, the CPLL/QPLL can still be reset based on the number of MGTs. This is how their reset is implemented in 0xBEFE. Would some improvements be required, they can come later on.
Possible fixes
Loop over the links, find the associated MGT, and configure and reset that one, applying a polarity swap if required.
Some care must be taken with the CTP7 that does not include yet the generic MGT firmware framework (but anyway uses the link number in the AMC
blocks).