Skip to content

Commit 6fe42e2

Browse files
mlichvardavem330
authored andcommitted
tg3: extend PTP gettime function to read system clock
This adds support for the PTP_SYS_OFFSET_EXTENDED ioctl. Cc: Richard Cochran <richardcochran@gmail.com> Cc: Michael Chan <michael.chan@broadcom.com> Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 018ed23 commit 6fe42e2

File tree

1 file changed

+13
-6
lines changed
  • drivers/net/ethernet/broadcom

1 file changed

+13
-6
lines changed

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6135,10 +6135,16 @@ static int tg3_setup_phy(struct tg3 *tp, bool force_reset)
61356135
}
61366136

61376137
/* tp->lock must be held */
6138-
static u64 tg3_refclk_read(struct tg3 *tp)
6138+
static u64 tg3_refclk_read(struct tg3 *tp, struct ptp_system_timestamp *sts)
61396139
{
6140-
u64 stamp = tr32(TG3_EAV_REF_CLCK_LSB);
6141-
return stamp | (u64)tr32(TG3_EAV_REF_CLCK_MSB) << 32;
6140+
u64 stamp;
6141+
6142+
ptp_read_system_prets(sts);
6143+
stamp = tr32(TG3_EAV_REF_CLCK_LSB);
6144+
ptp_read_system_postts(sts);
6145+
stamp |= (u64)tr32(TG3_EAV_REF_CLCK_MSB) << 32;
6146+
6147+
return stamp;
61426148
}
61436149

61446150
/* tp->lock must be held */
@@ -6229,13 +6235,14 @@ static int tg3_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
62296235
return 0;
62306236
}
62316237

6232-
static int tg3_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
6238+
static int tg3_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts,
6239+
struct ptp_system_timestamp *sts)
62336240
{
62346241
u64 ns;
62356242
struct tg3 *tp = container_of(ptp, struct tg3, ptp_info);
62366243

62376244
tg3_full_lock(tp, 0);
6238-
ns = tg3_refclk_read(tp);
6245+
ns = tg3_refclk_read(tp, sts);
62396246
ns += tp->ptp_adjust;
62406247
tg3_full_unlock(tp);
62416248

@@ -6330,7 +6337,7 @@ static const struct ptp_clock_info tg3_ptp_caps = {
63306337
.pps = 0,
63316338
.adjfreq = tg3_ptp_adjfreq,
63326339
.adjtime = tg3_ptp_adjtime,
6333-
.gettime64 = tg3_ptp_gettime,
6340+
.gettimex64 = tg3_ptp_gettimex,
63346341
.settime64 = tg3_ptp_settime,
63356342
.enable = tg3_ptp_enable,
63366343
};

0 commit comments

Comments
 (0)