Commit 27d64141 authored by David S. Miller's avatar David S. Miller

Merge branch 'ytja1103-ptp'

Radu Pirea says:

====================
Add PTP support for TJA1103

This is the PTP support for TJA1103.
The RX timestamp is found in the reserved2 field of the PTP package.
The TX timestamp has to be read from the phy registers. Reading of the
timestamp works with interrupts or with polling(that starts when
.nxp_c45_txtstamp is called).
The implementation of .adjtime is done by read modify write because there
is no way to atomically add/subtract a constant from the clock value.

I've moved scaled_ppm_to_ppb function from ptp_clock.c to
ptp_clock_kernel.h in  order to be able to build the driver without
PTP_1588_CLOCK=y.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 532062b0 514def5d
This diff is collapsed.
......@@ -63,27 +63,6 @@ static void enqueue_external_timestamp(struct timestamp_event_queue *queue,
spin_unlock_irqrestore(&queue->lock, flags);
}
s32 scaled_ppm_to_ppb(long ppm)
{
/*
* The 'freq' field in the 'struct timex' is in parts per
* million, but with a 16 bit binary fractional field.
*
* We want to calculate
*
* ppb = scaled_ppm * 1000 / 2^16
*
* which simplifies to
*
* ppb = scaled_ppm * 125 / 2^13
*/
s64 ppb = 1 + ppm;
ppb *= 125;
ppb >>= 13;
return (s32) ppb;
}
EXPORT_SYMBOL(scaled_ppm_to_ppb);
/* posix clock implementation */
static int ptp_clock_getres(struct posix_clock *pc, struct timespec64 *tp)
......
......@@ -186,6 +186,32 @@ struct ptp_clock_event {
};
};
/**
* scaled_ppm_to_ppb() - convert scaled ppm to ppb
*
* @ppm: Parts per million, but with a 16 bit binary fractional field
*/
static inline s32 scaled_ppm_to_ppb(long ppm)
{
/*
* The 'freq' field in the 'struct timex' is in parts per
* million, but with a 16 bit binary fractional field.
*
* We want to calculate
*
* ppb = scaled_ppm * 1000 / 2^16
*
* which simplifies to
*
* ppb = scaled_ppm * 125 / 2^13
*/
s64 ppb = 1 + ppm;
ppb *= 125;
ppb >>= 13;
return (s32)ppb;
}
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
/**
......@@ -229,14 +255,6 @@ extern void ptp_clock_event(struct ptp_clock *ptp,
extern int ptp_clock_index(struct ptp_clock *ptp);
/**
* scaled_ppm_to_ppb() - convert scaled ppm to ppb
*
* @ppm: Parts per million, but with a 16 bit binary fractional field
*/
extern s32 scaled_ppm_to_ppb(long ppm);
/**
* ptp_find_pin() - obtain the pin index of a given auxiliary function
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment