mirror of
https://github.com/torvalds/linux.git
synced 2024-12-12 22:23:55 +00:00
bnxt_en: PTP: Refactor PTP initialization functions
Making the ptp free and timecounter initialization code into separate functions so that later patches can use them. Cc: Richard Cochran <richardcochran@gmail.com> Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
2895c15310
commit
740c342e39
@ -714,6 +714,34 @@ static bool bnxt_pps_config_ok(struct bnxt *bp)
|
|||||||
return !(bp->fw_cap & BNXT_FW_CAP_PTP_PPS) == !ptp->ptp_info.pin_config;
|
return !(bp->fw_cap & BNXT_FW_CAP_PTP_PPS) == !ptp->ptp_info.pin_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void bnxt_ptp_timecounter_init(struct bnxt *bp, bool init_tc)
|
||||||
|
{
|
||||||
|
struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
|
||||||
|
|
||||||
|
if (!ptp->ptp_clock) {
|
||||||
|
memset(&ptp->cc, 0, sizeof(ptp->cc));
|
||||||
|
ptp->cc.read = bnxt_cc_read;
|
||||||
|
ptp->cc.mask = CYCLECOUNTER_MASK(48);
|
||||||
|
ptp->cc.shift = 0;
|
||||||
|
ptp->cc.mult = 1;
|
||||||
|
ptp->next_overflow_check = jiffies + BNXT_PHC_OVERFLOW_PERIOD;
|
||||||
|
}
|
||||||
|
if (init_tc)
|
||||||
|
timecounter_init(&ptp->tc, &ptp->cc, ktime_to_ns(ktime_get_real()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bnxt_ptp_free(struct bnxt *bp)
|
||||||
|
{
|
||||||
|
struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
|
||||||
|
|
||||||
|
if (ptp->ptp_clock) {
|
||||||
|
ptp_clock_unregister(ptp->ptp_clock);
|
||||||
|
ptp->ptp_clock = NULL;
|
||||||
|
kfree(ptp->ptp_info.pin_config);
|
||||||
|
ptp->ptp_info.pin_config = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int bnxt_ptp_init(struct bnxt *bp)
|
int bnxt_ptp_init(struct bnxt *bp)
|
||||||
{
|
{
|
||||||
struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
|
struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
|
||||||
@ -729,23 +757,12 @@ int bnxt_ptp_init(struct bnxt *bp)
|
|||||||
if (ptp->ptp_clock && bnxt_pps_config_ok(bp))
|
if (ptp->ptp_clock && bnxt_pps_config_ok(bp))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ptp->ptp_clock) {
|
bnxt_ptp_free(bp);
|
||||||
ptp_clock_unregister(ptp->ptp_clock);
|
|
||||||
ptp->ptp_clock = NULL;
|
|
||||||
kfree(ptp->ptp_info.pin_config);
|
|
||||||
ptp->ptp_info.pin_config = NULL;
|
|
||||||
}
|
|
||||||
atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS);
|
atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS);
|
||||||
spin_lock_init(&ptp->ptp_lock);
|
spin_lock_init(&ptp->ptp_lock);
|
||||||
|
|
||||||
memset(&ptp->cc, 0, sizeof(ptp->cc));
|
bnxt_ptp_timecounter_init(bp, true);
|
||||||
ptp->cc.read = bnxt_cc_read;
|
|
||||||
ptp->cc.mask = CYCLECOUNTER_MASK(48);
|
|
||||||
ptp->cc.shift = 0;
|
|
||||||
ptp->cc.mult = 1;
|
|
||||||
|
|
||||||
ptp->next_overflow_check = jiffies + BNXT_PHC_OVERFLOW_PERIOD;
|
|
||||||
timecounter_init(&ptp->tc, &ptp->cc, ktime_to_ns(ktime_get_real()));
|
|
||||||
|
|
||||||
ptp->ptp_info = bnxt_ptp_caps;
|
ptp->ptp_info = bnxt_ptp_caps;
|
||||||
if ((bp->fw_cap & BNXT_FW_CAP_PTP_PPS)) {
|
if ((bp->fw_cap & BNXT_FW_CAP_PTP_PPS)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user