Lines Matching full:phydev

130 	struct phy_device *phydev;  member
164 #define BRCM_PHY_MODEL(phydev) \ argument
165 ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
177 static void bcm_ptp_get_framesync_ts(struct phy_device *phydev, in bcm_ptp_get_framesync_ts() argument
182 bcm_phy_write_exp(phydev, HB_STAT_CTRL, HB_READ_START); in bcm_ptp_get_framesync_ts()
184 hb[0] = bcm_phy_read_exp(phydev, HB_REG_0); in bcm_ptp_get_framesync_ts()
185 hb[1] = bcm_phy_read_exp(phydev, HB_REG_1); in bcm_ptp_get_framesync_ts()
186 hb[2] = bcm_phy_read_exp(phydev, HB_REG_2); in bcm_ptp_get_framesync_ts()
187 hb[3] = bcm_phy_read_exp(phydev, HB_REG_3); in bcm_ptp_get_framesync_ts()
189 bcm_phy_write_exp(phydev, HB_STAT_CTRL, HB_READ_END); in bcm_ptp_get_framesync_ts()
190 bcm_phy_write_exp(phydev, HB_STAT_CTRL, 0); in bcm_ptp_get_framesync_ts()
196 static u16 bcm_ptp_framesync_disable(struct phy_device *phydev, u16 orig_ctrl) in bcm_ptp_framesync_disable() argument
200 bcm_phy_write_exp(phydev, NSE_CTRL, ctrl); in bcm_ptp_framesync_disable()
205 static void bcm_ptp_framesync_restore(struct phy_device *phydev, u16 orig_ctrl) in bcm_ptp_framesync_restore() argument
208 bcm_phy_write_exp(phydev, NSE_CTRL, orig_ctrl); in bcm_ptp_framesync_restore()
211 static void bcm_ptp_framesync(struct phy_device *phydev, u16 ctrl) in bcm_ptp_framesync() argument
214 bcm_phy_write_exp(phydev, NSE_CTRL, ctrl | NSE_CPU_FRAMESYNC); in bcm_ptp_framesync()
217 static int bcm_ptp_framesync_ts(struct phy_device *phydev, in bcm_ptp_framesync_ts() argument
225 ctrl = bcm_ptp_framesync_disable(phydev, orig_ctrl); in bcm_ptp_framesync_ts()
230 bcm_ptp_framesync(phydev, ctrl | NSE_CAPTURE_EN); in bcm_ptp_framesync_ts()
236 reg = bcm_phy_read_exp(phydev, INTR_STATUS); in bcm_ptp_framesync_ts()
238 bcm_ptp_get_framesync_ts(phydev, ts); in bcm_ptp_framesync_ts()
243 bcm_ptp_framesync_restore(phydev, orig_ctrl); in bcm_ptp_framesync_ts()
256 err = bcm_ptp_framesync_ts(priv->phydev, sts, ts, priv->nse_ctrl); in bcm_ptp_gettimex()
265 struct phy_device *phydev = priv->phydev; in bcm_ptp_settime_locked() local
269 ctrl = bcm_ptp_framesync_disable(phydev, priv->nse_ctrl); in bcm_ptp_settime_locked()
272 bcm_phy_write_exp(phydev, TIME_CODE_0, ts->tv_nsec); in bcm_ptp_settime_locked()
273 bcm_phy_write_exp(phydev, TIME_CODE_1, ts->tv_nsec >> 16); in bcm_ptp_settime_locked()
274 bcm_phy_write_exp(phydev, TIME_CODE_2, ts->tv_sec); in bcm_ptp_settime_locked()
275 bcm_phy_write_exp(phydev, TIME_CODE_3, ts->tv_sec >> 16); in bcm_ptp_settime_locked()
276 bcm_phy_write_exp(phydev, TIME_CODE_4, ts->tv_sec >> 32); in bcm_ptp_settime_locked()
280 bcm_phy_write_exp(phydev, NCO_TIME_0, ns >> 4); in bcm_ptp_settime_locked()
281 bcm_phy_write_exp(phydev, NCO_TIME_1, ns >> 20); in bcm_ptp_settime_locked()
282 bcm_phy_write_exp(phydev, NCO_TIME_2_CTRL, (ns >> 36) & 0xfff); in bcm_ptp_settime_locked()
285 bcm_phy_write_exp(phydev, SHADOW_LOAD, TIME_CODE_LOAD | NCO_TIME_LOAD); in bcm_ptp_settime_locked()
288 bcm_ptp_framesync(phydev, ctrl | NSE_INIT); in bcm_ptp_settime_locked()
290 bcm_ptp_framesync_restore(phydev, priv->nse_ctrl); in bcm_ptp_settime_locked()
315 err = bcm_ptp_framesync_ts(priv->phydev, NULL, &ts, priv->nse_ctrl); in bcm_ptp_adjtime_locked()
363 ctrl = bcm_ptp_framesync_disable(priv->phydev, priv->nse_ctrl); in bcm_ptp_adjfine()
365 bcm_phy_write_exp(priv->phydev, NCO_FREQ_LSB, freq); in bcm_ptp_adjfine()
366 bcm_phy_write_exp(priv->phydev, NCO_FREQ_MSB, freq >> 16); in bcm_ptp_adjfine()
368 bcm_phy_write_exp(priv->phydev, NCO_TIME_2_CTRL, FREQ_MDIO_SEL); in bcm_ptp_adjfine()
371 bcm_phy_write_exp(priv->phydev, SHADOW_LOAD, FREQ_LOAD); in bcm_ptp_adjfine()
373 bcm_ptp_framesync(priv->phydev, ctrl); in bcm_ptp_adjfine()
376 bcm_phy_write_exp(priv->phydev, SHADOW_LOAD, 0); in bcm_ptp_adjfine()
378 bcm_ptp_framesync_restore(priv->phydev, priv->nse_ctrl); in bcm_ptp_adjfine()
421 struct phy_device *phydev = priv->phydev; in bcm_ptp_get_tstamp() local
427 reg = bcm_phy_read_exp(phydev, INTR_STATUS); in bcm_ptp_get_tstamp()
433 bcm_phy_write_exp(phydev, TS_READ_CTRL, TS_READ_START); in bcm_ptp_get_tstamp()
435 ts[0] = bcm_phy_read_exp(phydev, TS_REG_0); in bcm_ptp_get_tstamp()
436 ts[1] = bcm_phy_read_exp(phydev, TS_REG_1); in bcm_ptp_get_tstamp()
437 ts[2] = bcm_phy_read_exp(phydev, TS_REG_2); in bcm_ptp_get_tstamp()
438 ts[3] = bcm_phy_read_exp(phydev, TS_REG_3); in bcm_ptp_get_tstamp()
441 capts->seq_id = bcm_phy_read_exp(priv->phydev, TS_INFO_0); in bcm_ptp_get_tstamp()
443 reg = bcm_phy_read_exp(phydev, TS_INFO_1); in bcm_ptp_get_tstamp()
447 bcm_phy_write_exp(phydev, TS_READ_CTRL, TS_READ_END); in bcm_ptp_get_tstamp()
448 bcm_phy_write_exp(phydev, TS_READ_CTRL, 0); in bcm_ptp_get_tstamp()
529 bcm_phy_write_exp(priv->phydev, NSE_CTRL, priv->nse_ctrl); in bcm_ptp_cancel_func()
540 struct phy_device *phydev = priv->phydev; in bcm_ptp_perout_work() local
553 bcm_ptp_framesync_ts(phydev, NULL, &ts, priv->nse_ctrl); in bcm_ptp_perout_work()
563 ctrl = bcm_ptp_framesync_disable(phydev, in bcm_ptp_perout_work()
566 bcm_phy_write_exp(phydev, SYNOUT_TS_0, ns & 0xfff0); in bcm_ptp_perout_work()
567 bcm_phy_write_exp(phydev, SYNOUT_TS_1, ns >> 16); in bcm_ptp_perout_work()
568 bcm_phy_write_exp(phydev, SYNOUT_TS_2, ns >> 32); in bcm_ptp_perout_work()
571 bcm_phy_write_exp(phydev, SHADOW_LOAD, SYNC_OUT_LOAD); in bcm_ptp_perout_work()
573 bcm_ptp_framesync(phydev, ctrl | NSE_ONESHOT_EN | NSE_INIT); in bcm_ptp_perout_work()
576 bcm_ptp_framesync_restore(phydev, priv->nse_ctrl); in bcm_ptp_perout_work()
587 struct phy_device *phydev = priv->phydev; in bcm_ptp_perout_locked() local
615 bcm_phy_write_exp(phydev, SYNC_OUT_0, period); in bcm_ptp_perout_locked()
618 bcm_phy_write_exp(phydev, SYNC_OUT_1, val); in bcm_ptp_perout_locked()
621 bcm_phy_write_exp(phydev, SYNC_OUT_2, val); in bcm_ptp_perout_locked()
637 struct phy_device *phydev = priv->phydev; in bcm_ptp_extts_work() local
650 reg = bcm_phy_read_exp(phydev, INTR_STATUS); in bcm_ptp_extts_work()
654 bcm_ptp_get_framesync_ts(phydev, &ts); in bcm_ptp_extts_work()
668 struct phy_device *phydev = priv->phydev; in bcm_ptp_extts_locked() local
676 bcm_ptp_framesync_disable(phydev, priv->nse_ctrl); in bcm_ptp_extts_locked()
680 bcm_ptp_framesync_restore(phydev, priv->nse_ctrl); in bcm_ptp_extts_locked()
822 bcm_phy_write_exp(priv->phydev, TX_EVENT_MODE, mode); in bcm_ptp_hwtstamp()
829 bcm_phy_write_exp(priv->phydev, RX_EVENT_MODE, mode); in bcm_ptp_hwtstamp()
831 bcm_phy_write_exp(priv->phydev, SLICE_CTRL, ctrl); in bcm_ptp_hwtstamp()
834 bcm_phy_write_exp(priv->phydev, TX_TS_CAPTURE, TX_TS_CAP_EN); in bcm_ptp_hwtstamp()
873 void bcm_ptp_config_init(struct phy_device *phydev) in bcm_ptp_config_init() argument
876 bcm_phy_write_exp(phydev, NSE_CTRL, NSE_GMODE_EN | NSE_INIT); in bcm_ptp_config_init()
879 bcm_phy_write_exp(phydev, TIME_SYNC, TIME_SYNC_EN); in bcm_ptp_config_init()
882 bcm_phy_write_exp(phydev, DPLL_SELECT, DPLL_HB_MODE2); in bcm_ptp_config_init()
885 bcm_phy_write_exp(phydev, TIMECODE_CTRL, TX_TIMECODE_SEL); in bcm_ptp_config_init()
888 bcm_phy_write_exp(phydev, SHADOW_CTRL, FREQ_LOAD); in bcm_ptp_config_init()
890 bcm_phy_write_exp(phydev, SYNC_IN_DIVIDER, 1); in bcm_ptp_config_init()
906 priv->phydev->mii_ts = &priv->mii_ts; in bcm_ptp_init()
909 struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev) in bcm_ptp_probe() argument
914 switch (BRCM_PHY_MODEL(phydev)) { in bcm_ptp_probe()
921 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in bcm_ptp_probe()
930 clock = ptp_clock_register(&priv->ptp_info, &phydev->mdio.dev); in bcm_ptp_probe()
936 phydev->default_timestamp = true; in bcm_ptp_probe()
938 priv->phydev = phydev; in bcm_ptp_probe()