Lines Matching defs:phydev

130 	struct phy_device *phydev;
164 #define BRCM_PHY_MODEL(phydev) \
165 ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
177 static void bcm_ptp_get_framesync_ts(struct phy_device *phydev,
182 bcm_phy_write_exp(phydev, HB_STAT_CTRL, HB_READ_START);
184 hb[0] = bcm_phy_read_exp(phydev, HB_REG_0);
185 hb[1] = bcm_phy_read_exp(phydev, HB_REG_1);
186 hb[2] = bcm_phy_read_exp(phydev, HB_REG_2);
187 hb[3] = bcm_phy_read_exp(phydev, HB_REG_3);
189 bcm_phy_write_exp(phydev, HB_STAT_CTRL, HB_READ_END);
190 bcm_phy_write_exp(phydev, HB_STAT_CTRL, 0);
196 static u16 bcm_ptp_framesync_disable(struct phy_device *phydev, u16 orig_ctrl)
200 bcm_phy_write_exp(phydev, NSE_CTRL, ctrl);
205 static void bcm_ptp_framesync_restore(struct phy_device *phydev, u16 orig_ctrl)
208 bcm_phy_write_exp(phydev, NSE_CTRL, orig_ctrl);
211 static void bcm_ptp_framesync(struct phy_device *phydev, u16 ctrl)
214 bcm_phy_write_exp(phydev, NSE_CTRL, ctrl | NSE_CPU_FRAMESYNC);
217 static int bcm_ptp_framesync_ts(struct phy_device *phydev,
225 ctrl = bcm_ptp_framesync_disable(phydev, orig_ctrl);
230 bcm_ptp_framesync(phydev, ctrl | NSE_CAPTURE_EN);
236 reg = bcm_phy_read_exp(phydev, INTR_STATUS);
238 bcm_ptp_get_framesync_ts(phydev, ts);
243 bcm_ptp_framesync_restore(phydev, orig_ctrl);
256 err = bcm_ptp_framesync_ts(priv->phydev, sts, ts, priv->nse_ctrl);
265 struct phy_device *phydev = priv->phydev;
269 ctrl = bcm_ptp_framesync_disable(phydev, priv->nse_ctrl);
272 bcm_phy_write_exp(phydev, TIME_CODE_0, ts->tv_nsec);
273 bcm_phy_write_exp(phydev, TIME_CODE_1, ts->tv_nsec >> 16);
274 bcm_phy_write_exp(phydev, TIME_CODE_2, ts->tv_sec);
275 bcm_phy_write_exp(phydev, TIME_CODE_3, ts->tv_sec >> 16);
276 bcm_phy_write_exp(phydev, TIME_CODE_4, ts->tv_sec >> 32);
280 bcm_phy_write_exp(phydev, NCO_TIME_0, ns >> 4);
281 bcm_phy_write_exp(phydev, NCO_TIME_1, ns >> 20);
282 bcm_phy_write_exp(phydev, NCO_TIME_2_CTRL, (ns >> 36) & 0xfff);
285 bcm_phy_write_exp(phydev, SHADOW_LOAD, TIME_CODE_LOAD | NCO_TIME_LOAD);
288 bcm_ptp_framesync(phydev, ctrl | NSE_INIT);
290 bcm_ptp_framesync_restore(phydev, priv->nse_ctrl);
315 err = bcm_ptp_framesync_ts(priv->phydev, NULL, &ts, priv->nse_ctrl);
363 ctrl = bcm_ptp_framesync_disable(priv->phydev, priv->nse_ctrl);
365 bcm_phy_write_exp(priv->phydev, NCO_FREQ_LSB, freq);
366 bcm_phy_write_exp(priv->phydev, NCO_FREQ_MSB, freq >> 16);
368 bcm_phy_write_exp(priv->phydev, NCO_TIME_2_CTRL, FREQ_MDIO_SEL);
371 bcm_phy_write_exp(priv->phydev, SHADOW_LOAD, FREQ_LOAD);
373 bcm_ptp_framesync(priv->phydev, ctrl);
376 bcm_phy_write_exp(priv->phydev, SHADOW_LOAD, 0);
378 bcm_ptp_framesync_restore(priv->phydev, priv->nse_ctrl);
421 struct phy_device *phydev = priv->phydev;
427 reg = bcm_phy_read_exp(phydev, INTR_STATUS);
433 bcm_phy_write_exp(phydev, TS_READ_CTRL, TS_READ_START);
435 ts[0] = bcm_phy_read_exp(phydev, TS_REG_0);
436 ts[1] = bcm_phy_read_exp(phydev, TS_REG_1);
437 ts[2] = bcm_phy_read_exp(phydev, TS_REG_2);
438 ts[3] = bcm_phy_read_exp(phydev, TS_REG_3);
441 capts->seq_id = bcm_phy_read_exp(priv->phydev, TS_INFO_0);
443 reg = bcm_phy_read_exp(phydev, TS_INFO_1);
447 bcm_phy_write_exp(phydev, TS_READ_CTRL, TS_READ_END);
448 bcm_phy_write_exp(phydev, TS_READ_CTRL, 0);
529 bcm_phy_write_exp(priv->phydev, NSE_CTRL, priv->nse_ctrl);
540 struct phy_device *phydev = priv->phydev;
553 bcm_ptp_framesync_ts(phydev, NULL, &ts, priv->nse_ctrl);
563 ctrl = bcm_ptp_framesync_disable(phydev,
566 bcm_phy_write_exp(phydev, SYNOUT_TS_0, ns & 0xfff0);
567 bcm_phy_write_exp(phydev, SYNOUT_TS_1, ns >> 16);
568 bcm_phy_write_exp(phydev, SYNOUT_TS_2, ns >> 32);
571 bcm_phy_write_exp(phydev, SHADOW_LOAD, SYNC_OUT_LOAD);
573 bcm_ptp_framesync(phydev, ctrl | NSE_ONESHOT_EN | NSE_INIT);
576 bcm_ptp_framesync_restore(phydev, priv->nse_ctrl);
587 struct phy_device *phydev = priv->phydev;
614 bcm_phy_write_exp(phydev, SYNC_OUT_0, period);
617 bcm_phy_write_exp(phydev, SYNC_OUT_1, val);
620 bcm_phy_write_exp(phydev, SYNC_OUT_2, val);
636 struct phy_device *phydev = priv->phydev;
649 reg = bcm_phy_read_exp(phydev, INTR_STATUS);
653 bcm_ptp_get_framesync_ts(phydev, &ts);
667 struct phy_device *phydev = priv->phydev;
675 bcm_ptp_framesync_disable(phydev, priv->nse_ctrl);
679 bcm_ptp_framesync_restore(phydev, priv->nse_ctrl);
821 bcm_phy_write_exp(priv->phydev, TX_EVENT_MODE, mode);
828 bcm_phy_write_exp(priv->phydev, RX_EVENT_MODE, mode);
830 bcm_phy_write_exp(priv->phydev, SLICE_CTRL, ctrl);
833 bcm_phy_write_exp(priv->phydev, TX_TS_CAPTURE, TX_TS_CAP_EN);
872 void bcm_ptp_config_init(struct phy_device *phydev)
875 bcm_phy_write_exp(phydev, NSE_CTRL, NSE_GMODE_EN | NSE_INIT);
878 bcm_phy_write_exp(phydev, TIME_SYNC, TIME_SYNC_EN);
881 bcm_phy_write_exp(phydev, DPLL_SELECT, DPLL_HB_MODE2);
884 bcm_phy_write_exp(phydev, TIMECODE_CTRL, TX_TIMECODE_SEL);
887 bcm_phy_write_exp(phydev, SHADOW_CTRL, FREQ_LOAD);
889 bcm_phy_write_exp(phydev, SYNC_IN_DIVIDER, 1);
905 priv->phydev->mii_ts = &priv->mii_ts;
908 struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev)
913 switch (BRCM_PHY_MODEL(phydev)) {
920 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
929 clock = ptp_clock_register(&priv->ptp_info, &phydev->mdio.dev);
934 priv->phydev = phydev;