mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-08 18:35:20 +02:00
net: fec: Move fec_ptp_read()
to the top of the file
commit 4374a1fe58
upstream.
This function is used in `fec_ptp_enable_pps()` through
struct cyclecounter read(). Moving the declaration makes
it clearer, what's happening.
Suggested-by: Frank Li <Frank.li@nxp.com>
Link: https://lore.kernel.org/netdev/20240805144754.2384663-1-csokas.bence@prolan.hu/T/#ma6c21ad264016c24612048b1483769eaff8cdf20
Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240812094713.2883476-1-csokas.bence@prolan.hu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
677f1df179
commit
1e1eb62c40
|
@ -90,6 +90,30 @@
|
||||||
#define FEC_PTP_MAX_NSEC_PERIOD 4000000000ULL
|
#define FEC_PTP_MAX_NSEC_PERIOD 4000000000ULL
|
||||||
#define FEC_PTP_MAX_NSEC_COUNTER 0x80000000ULL
|
#define FEC_PTP_MAX_NSEC_COUNTER 0x80000000ULL
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fec_ptp_read - read raw cycle counter (to be used by time counter)
|
||||||
|
* @cc: the cyclecounter structure
|
||||||
|
*
|
||||||
|
* this function reads the cyclecounter registers and is called by the
|
||||||
|
* cyclecounter structure used to construct a ns counter from the
|
||||||
|
* arbitrary fixed point registers
|
||||||
|
*/
|
||||||
|
static u64 fec_ptp_read(const struct cyclecounter *cc)
|
||||||
|
{
|
||||||
|
struct fec_enet_private *fep =
|
||||||
|
container_of(cc, struct fec_enet_private, cc);
|
||||||
|
u32 tempval;
|
||||||
|
|
||||||
|
tempval = readl(fep->hwp + FEC_ATIME_CTRL);
|
||||||
|
tempval |= FEC_T_CTRL_CAPTURE;
|
||||||
|
writel(tempval, fep->hwp + FEC_ATIME_CTRL);
|
||||||
|
|
||||||
|
if (fep->quirks & FEC_QUIRK_BUG_CAPTURE)
|
||||||
|
udelay(1);
|
||||||
|
|
||||||
|
return readl(fep->hwp + FEC_ATIME);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fec_ptp_enable_pps
|
* fec_ptp_enable_pps
|
||||||
* @fep: the fec_enet_private structure handle
|
* @fep: the fec_enet_private structure handle
|
||||||
|
@ -136,7 +160,7 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable)
|
||||||
* NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds
|
* NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds
|
||||||
* to current timer would be next second.
|
* to current timer would be next second.
|
||||||
*/
|
*/
|
||||||
tempval = fep->cc.read(&fep->cc);
|
tempval = fec_ptp_read(&fep->cc);
|
||||||
/* Convert the ptp local counter to 1588 timestamp */
|
/* Convert the ptp local counter to 1588 timestamp */
|
||||||
ns = timecounter_cyc2time(&fep->tc, tempval);
|
ns = timecounter_cyc2time(&fep->tc, tempval);
|
||||||
ts = ns_to_timespec64(ns);
|
ts = ns_to_timespec64(ns);
|
||||||
|
@ -271,30 +295,6 @@ static enum hrtimer_restart fec_ptp_pps_perout_handler(struct hrtimer *timer)
|
||||||
return HRTIMER_NORESTART;
|
return HRTIMER_NORESTART;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* fec_ptp_read - read raw cycle counter (to be used by time counter)
|
|
||||||
* @cc: the cyclecounter structure
|
|
||||||
*
|
|
||||||
* this function reads the cyclecounter registers and is called by the
|
|
||||||
* cyclecounter structure used to construct a ns counter from the
|
|
||||||
* arbitrary fixed point registers
|
|
||||||
*/
|
|
||||||
static u64 fec_ptp_read(const struct cyclecounter *cc)
|
|
||||||
{
|
|
||||||
struct fec_enet_private *fep =
|
|
||||||
container_of(cc, struct fec_enet_private, cc);
|
|
||||||
u32 tempval;
|
|
||||||
|
|
||||||
tempval = readl(fep->hwp + FEC_ATIME_CTRL);
|
|
||||||
tempval |= FEC_T_CTRL_CAPTURE;
|
|
||||||
writel(tempval, fep->hwp + FEC_ATIME_CTRL);
|
|
||||||
|
|
||||||
if (fep->quirks & FEC_QUIRK_BUG_CAPTURE)
|
|
||||||
udelay(1);
|
|
||||||
|
|
||||||
return readl(fep->hwp + FEC_ATIME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fec_ptp_start_cyclecounter - create the cycle counter from hw
|
* fec_ptp_start_cyclecounter - create the cycle counter from hw
|
||||||
* @ndev: network device
|
* @ndev: network device
|
||||||
|
|
Loading…
Reference in New Issue
Block a user