Skip to content

Commit dd19dcb

Browse files
yangbolu1991MaureenHelm
authored andcommitted
drivers: eth_xmc4xxx: adjust ptp clock rate based on nominal frequency
Adjusted ptp clock rate based on nominal frequency. Signed-off-by: Yangbo Lu <[email protected]>
1 parent 2d82a0d commit dd19dcb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/ethernet/eth_xmc4xxx.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct eth_xmc4xxx_data {
104104
struct net_buf *rx_frag_list[NUM_RX_DMA_DESCRIPTORS];
105105
#if defined(CONFIG_PTP_CLOCK_XMC4XXX)
106106
const struct device *ptp_clock;
107+
uint32_t timestamp_addend;
107108
#endif
108109
};
109110

@@ -878,7 +879,15 @@ static int eth_xmc4xxx_init(const struct device *dev)
878879
reg |= ETH_MAC_FRAME_FILTER_PM_Msk;
879880
dev_cfg->regs->MAC_FRAME_FILTER = reg;
880881

881-
return eth_xmc4xxx_init_timestamp_control_reg(dev_cfg->regs);
882+
ret = eth_xmc4xxx_init_timestamp_control_reg(dev_cfg->regs);
883+
if (ret != 0) {
884+
return ret;
885+
}
886+
887+
#if defined(CONFIG_PTP_CLOCK_XMC4XXX)
888+
dev_data->timestamp_addend = dev_cfg->regs->TIMESTAMP_ADDEND;
889+
#endif
890+
return 0;
882891
}
883892

884893
static enum ethernet_hw_caps eth_xmc4xxx_capabilities(const struct device *dev)
@@ -1090,7 +1099,8 @@ static int eth_xmc4xxx_ptp_clock_rate_adjust(const struct device *dev, double ra
10901099
{
10911100
struct ptp_context *ptp_context = dev->data;
10921101
const struct eth_xmc4xxx_config *dev_cfg = ptp_context->eth_dev->config;
1093-
uint64_t K = dev_cfg->regs->TIMESTAMP_ADDEND;
1102+
struct eth_xmc4xxx_data *dev_data = ptp_context->eth_dev->data;
1103+
uint64_t K = dev_data->timestamp_addend;
10941104

10951105
if (ratio < ETH_PTP_RATE_ADJUST_RATIO_MIN || ratio > ETH_PTP_RATE_ADJUST_RATIO_MAX) {
10961106
return -EINVAL;

0 commit comments

Comments
 (0)