Skip to content
  • Marek Vasut's avatar
    can: ifi: Fix clock generator configuration · 99312c37
    Marek Vasut authored
    
    
    The clock generation does not match reality when using the CAN IP
    core outside of the FPGA design. This patch fixes the computation
    of values which are programmed into the clock generator registers.
    
    First, there are some off-by-one errors which manifest themselves
    only when communicating with different controller, so those are
    fixed.
    
    Second, the bits in the clock generator registers have different
    meaning depending on whether the core is in ISO CANFD mode or any
    of the other modes (BOSCH CANFD or CAN2.0). Detect the ISO CANFD
    mode and fix handling of this special case of clock configuration.
    
    Finally, the CAN clock speed is in CANCLOCK register, not SYSCLOCK
    register, so fix this as well.
    
    Signed-off-by: default avatarMarek Vasut <marex@denx.de>
    Cc: Marc Kleine-Budde <mkl@pengutronix.de>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Oliver Hartkopp <socketcan@hartkopp.net>
    Cc: Wolfgang Grandegger <wg@grandegger.com>
    Reviewed-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
    Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
    99312c37