diff --git a/include/osi_core.h b/include/osi_core.h index d28f2d6..2d2c54b 100644 --- a/include/osi_core.h +++ b/include/osi_core.h @@ -231,8 +231,8 @@ struct osi_core_ops { unsigned int nsec); /** Called to set the addend value to adjust the time */ int (*config_addend)(void *addr, unsigned int addend); - /** Called to adjust the system time */ - int (*adjust_systime)(void *addr, unsigned int sec, unsigned int nsec, + /** Called to adjust the mac time */ + int (*adjust_mactime)(void *addr, unsigned int sec, unsigned int nsec, unsigned int neg_adj, unsigned int one_nsec_accuracy); /** Called to get the current time from MAC */ @@ -350,7 +350,7 @@ struct osi_core_priv_data { }; /** - * @brief osi_poll_for_swr - Poll Software reset bit in MAC HW + * @brief osi_poll_for_mac_reset_complete - Poll Software reset bit in MAC HW * * Algorithm: Invokes EQOS routine to check for SWR (software reset) * bit in DMA Basic mode register to make sure IP reset was successful. @@ -363,7 +363,7 @@ struct osi_core_priv_data { * @retval -1 on failure. */ -int osi_poll_for_swr(struct osi_core_priv_data *osi_core); +int osi_poll_for_mac_reset_complete(struct osi_core_priv_data *osi_core); /** * @brief osi_set_mdc_clk_rate - Derive MDC clock based on provided AXI_CBB clk. @@ -393,7 +393,8 @@ int osi_set_mdc_clk_rate(struct osi_core_priv_data *osi_core, * @param[in] rx_fifo_size: OSI core private data structure. * * @note - * 1) MAC should be out of reset. See osi_poll_for_swr() for details. + * 1) MAC should be out of reset. See osi_poll_for_mac_reset_complete() + * for details. * 2) osi_core->base needs to be filled based on ioremap. * 3) osi_core->num_mtl_queues needs to be filled. * 4)osi_core->mtl_queues[qinx] need to be filled. @@ -900,13 +901,13 @@ int osi_set_systime_to_mac(struct osi_core_priv_data *osi_core, int osi_adjust_freq(struct osi_core_priv_data *osi_core, int ppb); /** - * @brief osi_adjust_time - Adjust time + * @brief osi_adjust_time - Adjust MAC time with system time * * Algorithm: Adjust/update the MAC time (delta time from MAC to system time * passed in nanoseconds, can be + or -). * * @param[in] osi_core: OSI core private data structure. - * @param[in] delta: Delta time + * @param[in] nsec_delta: Delta time in nano seconds * * @note * 1) MAC should be init and started. see osi_start_mac() @@ -915,7 +916,7 @@ int osi_adjust_freq(struct osi_core_priv_data *osi_core, int ppb); * @retval 0 on success * @retval -1 on failure. */ -int osi_adjust_time(struct osi_core_priv_data *osi_core, long delta); +int osi_adjust_time(struct osi_core_priv_data *osi_core, long long nsec_delta); /** * @brief osi_get_systime_from_mac - Get system time diff --git a/osi/core/eqos_core.c b/osi/core/eqos_core.c index edadd7c..9d380ee 100644 --- a/osi/core/eqos_core.c +++ b/osi/core/eqos_core.c @@ -1325,7 +1325,8 @@ static void eqos_configure_dma(void *base) * @param[in] tx_fifo_size: MTL TX FIFO size * @param[in] rx_fifo_size: MTL RX FIFO size * - * @note 1) MAC should be out of reset. See osi_poll_for_swr() for details. + * @note 1) MAC should be out of reset. See osi_poll_for_mac_reset_complete() + * for details. * 2) osi_core->base needs to be filled based on ioremap. * 3) osi_core->num_mtl_queues needs to be filled. * 4) osi_core->mtl_queues[qinx] need to be filled. @@ -2946,9 +2947,9 @@ static inline int eqos_poll_for_update_ts_complete(void *addr, } /** - * @brief eqos_adjust_systime - Adjust system time + * @brief eqos_adjust_mactime - Adjust MAC time with system time * - * Algorithm: Update the system time + * Algorithm: Update MAC time with system time * * @param[in] addr: Base address indicating the start of * memory mapped IO region of the MAC. @@ -2963,7 +2964,7 @@ static inline int eqos_poll_for_update_ts_complete(void *addr, * @retval 0 on success * @retval -1 on failure. */ -static int eqos_adjust_systime(void *addr, unsigned int sec, unsigned int nsec, +static int eqos_adjust_mactime(void *addr, unsigned int sec, unsigned int nsec, unsigned int add_sub, unsigned int one_nsec_accuracy) { @@ -3336,7 +3337,7 @@ static struct osi_core_ops eqos_core_ops = { .update_vlan_id = eqos_update_vlan_id, .set_systime_to_mac = eqos_set_systime_to_mac, .config_addend = eqos_config_addend, - .adjust_systime = eqos_adjust_systime, + .adjust_mactime = eqos_adjust_mactime, .get_systime_from_mac = eqos_get_systime_from_mac, .config_tscr = eqos_config_tscr, .config_ssir = eqos_config_ssir, diff --git a/osi/core/libnvethernetrm.export b/osi/core/libnvethernetrm.export index 9808256..9fe8f2e 100644 --- a/osi/core/libnvethernetrm.export +++ b/osi/core/libnvethernetrm.export @@ -26,7 +26,7 @@ osi_init_core_ops osi_write_phy_reg osi_read_phy_reg -osi_poll_for_swr +osi_poll_for_mac_reset_complete osi_set_mdc_clk_rate osi_hw_core_init osi_hw_core_deinit diff --git a/osi/core/osi_core.c b/osi/core/osi_core.c index 7893876..d626287 100644 --- a/osi/core/osi_core.c +++ b/osi/core/osi_core.c @@ -192,7 +192,7 @@ int osi_init_core_ops(struct osi_core_priv_data *osi_core) return -1; } -int osi_poll_for_swr(struct osi_core_priv_data *osi_core) +int osi_poll_for_mac_reset_complete(struct osi_core_priv_data *osi_core) { if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && (osi_core->ops->poll_for_swr != OSI_NULL)) { @@ -773,7 +773,7 @@ int osi_adjust_freq(struct osi_core_priv_data *osi_core, int ppb) return ret; } -int osi_adjust_time(struct osi_core_priv_data *osi_core, long delta) +int osi_adjust_time(struct osi_core_priv_data *osi_core, long long nsec_delta) { unsigned int neg_adj = 0; unsigned int sec = 0, nsec = 0; @@ -782,11 +782,11 @@ int osi_adjust_time(struct osi_core_priv_data *osi_core, long delta) unsigned long udelta = 0; int ret = -1; - if (delta < 0) { + if (nsec_delta < 0) { neg_adj = 1; - delta = -delta; + nsec_delta = -nsec_delta; } - udelta = (unsigned long) delta; + udelta = (unsigned long long) nsec_delta; quotient = div_u64_rem(udelta, OSI_NSEC_PER_SEC, &reminder); if (quotient <= UINT_MAX) { sec = (unsigned int)quotient; @@ -800,8 +800,8 @@ int osi_adjust_time(struct osi_core_priv_data *osi_core, long delta) } if ((osi_core != OSI_NULL) && (osi_core->ops != OSI_NULL) && - (osi_core->ops->adjust_systime != OSI_NULL)) { - ret = osi_core->ops->adjust_systime(osi_core->base, sec, nsec, + (osi_core->ops->adjust_mactime != OSI_NULL)) { + ret = osi_core->ops->adjust_mactime(osi_core->base, sec, nsec, neg_adj, osi_core->ptp_config.one_nsec_accuracy); }