diff --git a/include/osi_common.h b/include/osi_common.h index d1f5ede..f050c52 100644 --- a/include/osi_common.h +++ b/include/osi_common.h @@ -37,6 +37,7 @@ /* System clock is 62.5MHz */ #define OSI_ETHER_SYSCLOCK 62500000U +#define OSI_PTP_REQ_CLK_FREQ 250000000U #define OSI_ONE_MEGA_HZ 1000000U #define OSI_MAX_RX_COALESCE_USEC 1020U #define OSI_MIN_RX_COALESCE_USEC 3U diff --git a/osi/core/eqos_core.c b/osi/core/eqos_core.c index 7e21c28..c8626bc 100644 --- a/osi/core/eqos_core.c +++ b/osi/core/eqos_core.c @@ -3151,7 +3151,7 @@ static void eqos_config_tscr(void *addr, unsigned int ptp_filter) * * @param[in] addr: Base address indicating the start of * memory mapped IO region of the MAC. - * @param[in] ptp_clock: PTP clock + * @param[in] ptp_clock: PTP required clock frequency * * @note MAC should be init and started. see osi_start_mac() */ @@ -3162,14 +3162,14 @@ static void eqos_config_ssir(void *addr, unsigned int ptp_clock) mac_tcr = osi_readl((unsigned char *)addr + EQOS_MAC_TCR); - /* convert the PTP_CLOCK to nano second. + /* convert the PTP required clock frequency to nano second. * formula is : ((1/ptp_clock) * 1000000000) - * where, ptp_clock = 50MHz if FINE correction - * and ptp_clock = EQOS_SYSCLOCK if COARSE correction + * where, ptp_clock = OSI_PTP_REQ_CLK_FREQ if FINE correction + * and ptp_clock = PTP reference clock if COARSE correction */ if ((mac_tcr & EQOS_MAC_TCR_TSCFUPDT) == EQOS_MAC_TCR_TSCFUPDT) { - val = ((1U * OSI_NSEC_PER_SEC) / OSI_ETHER_SYSCLOCK); + val = ((1U * OSI_NSEC_PER_SEC) / OSI_PTP_REQ_CLK_FREQ); } else { val = ((1U * OSI_NSEC_PER_SEC) / ptp_clock); } diff --git a/osi/core/osi_core.c b/osi/core/osi_core.c index 57eed58..dc40d89 100644 --- a/osi/core/osi_core.c +++ b/osi/core/osi_core.c @@ -869,13 +869,13 @@ int osi_ptp_configuration(struct osi_core_priv_data *osi_core, /* formula for calculating addend value is * addend = 2^32/freq_div_ratio; - * where, freq_div_ratio = EQOS_SYSCLOCK/50MHz - * hence, addend = ((2^32) * 50MHz)/EQOS_SYSCLOCK; - * NOTE: EQOS_SYSCLOCK must be >= 50MHz to achive 20ns accuracy. + * where, freq_div_ratio = ptp_ref_clk_rate/OSI_PTP_REQ_CLK_FREQ * 2^x * y == (y << x), hence - * 2^32 * 6250000 ==> (6250000 << 32) + * 2^32 * OSI_PTP_REQ_CLK_FREQ == (OSI_PTP_REQ_CLK_FREQ << 32) + * so addend = (2^32 * OSI_PTP_REQ_CLK_FREQ)/ptp_ref_clk_rate; + * which is (OSI_PTP_REQ_CLK_FREQ << 32)/ptp_ref_clk_rate; */ - temp = ((unsigned long)OSI_ETHER_SYSCLOCK << 32); + temp = ((unsigned long)OSI_PTP_REQ_CLK_FREQ << 32); temp1 = div_u64(temp, (unsigned long)osi_core->ptp_config.ptp_ref_clk_rate); if (temp1 < UINT_MAX) {