Skip to content
  • Andreas Pretzsch's avatar
    net: phy: micrel: fix KSZ9031 clock skew for values greater 0ps · 3b4cda34
    Andreas Pretzsch authored and Joe Hershberger's avatar Joe Hershberger committed
    
    
    For KSZ9021, all skew register fields are 4-bit wide.
    For KSZ9031, the clock skew register fields are 5-bit wide.
    
    The common code in ksz90x1_of_config_group calculating the combined
    register value checks if the requested value is above the maximum
    and uses this maximum if so. The calculation of this maximum uses
    the register width, but the check itself does not. It uses a hardcoded
    value of 0xf, which is too low in case of the 5-bit clock (0x1f).
    This detail was probably lost during driver unification.
    
    Effect (only for KSZ9031 clock skews): For values greater 900 (== 0ps),
    this silently results in 1860 (== +960ps) instead of the requested one.
    
    Fix the check by using the bit width instead of hardcoded value(s).
    
    Signed-off-by: default avatarAndreas Pretzsch <apr@cn-eng.de>
    Acked-by: Joe Hershberger's avatarJoe Hershberger <joe.hershberger@ni.com>
    3b4cda34