Lines Matching full:channel

41 static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm);
242 static int arm_tod_read_trig_sel_refclk(struct idtcm_channel *channel, u8 ref) in arm_tod_read_trig_sel_refclk() argument
244 struct idtcm *idtcm = channel->idtcm; in arm_tod_read_trig_sel_refclk()
252 err = idtcm_write(idtcm, channel->tod_read_secondary, in arm_tod_read_trig_sel_refclk()
259 err = idtcm_write(idtcm, channel->tod_read_secondary, tod_read_cmd, in arm_tod_read_trig_sel_refclk()
273 static int idtcm_extts_enable(struct idtcm_channel *channel, in idtcm_extts_enable() argument
283 idtcm = channel->idtcm; in idtcm_extts_enable()
303 /* Use the pin configured for the channel */ in idtcm_extts_enable()
304 ref = ptp_find_pin(channel->ptp_clock, PTP_PF_EXTTS, channel->tod); in idtcm_extts_enable()
308 __func__, channel->tod); in idtcm_extts_enable()
312 err = arm_tod_read_trig_sel_refclk(&idtcm->channel[index], ref); in idtcm_extts_enable()
316 idtcm->event_channel[index] = channel; in idtcm_extts_enable()
317 idtcm->channel[index].refn = ref; in idtcm_extts_enable()
398 static int _idtcm_gettime_triggered(struct idtcm_channel *channel, in _idtcm_gettime_triggered() argument
401 struct idtcm *idtcm = channel->idtcm; in _idtcm_gettime_triggered()
407 err = idtcm_read(idtcm, channel->tod_read_secondary, in _idtcm_gettime_triggered()
415 err = idtcm_read(idtcm, channel->tod_read_secondary, in _idtcm_gettime_triggered()
423 static int _idtcm_gettime(struct idtcm_channel *channel, in _idtcm_gettime() argument
426 struct idtcm *idtcm = channel->idtcm; in _idtcm_gettime()
440 err = idtcm_read(idtcm, channel->tod_read_primary, in _idtcm_gettime()
447 err = idtcm_read(idtcm, channel->tod_read_primary, in _idtcm_gettime()
465 extts_channel = &idtcm->channel[todn]; in idtcm_extts_check_channel()
484 static int _idtcm_gettime_immediate(struct idtcm_channel *channel, in _idtcm_gettime_immediate() argument
487 struct idtcm *idtcm = channel->idtcm; in _idtcm_gettime_immediate()
493 err = idtcm_write(idtcm, channel->tod_read_primary, in _idtcm_gettime_immediate()
498 return _idtcm_gettime(channel, ts, 10); in _idtcm_gettime_immediate()
628 static int idtcm_sync_pps_output(struct idtcm_channel *channel) in idtcm_sync_pps_output() argument
630 struct idtcm *idtcm = channel->idtcm; in idtcm_sync_pps_output()
638 u16 output_mask = channel->output_mask; in idtcm_sync_pps_output()
695 err = _sync_pll_output(idtcm, pll, channel->sync_src, in idtcm_sync_pps_output()
705 static int _idtcm_set_dpll_hw_tod(struct idtcm_channel *channel, in _idtcm_set_dpll_hw_tod() argument
709 struct idtcm *idtcm = channel->idtcm; in _idtcm_set_dpll_hw_tod()
717 err = idtcm_read(idtcm, channel->hw_dpll_n, HW_DPLL_TOD_CTRL_1, in _idtcm_set_dpll_hw_tod()
725 err = idtcm_write(idtcm, channel->hw_dpll_n, HW_DPLL_TOD_CTRL_1, in _idtcm_set_dpll_hw_tod()
735 err = idtcm_write(idtcm, channel->hw_dpll_n, in _idtcm_set_dpll_hw_tod()
744 err = idtcm_write(idtcm, channel->hw_dpll_n, HW_DPLL_TOD_CTRL_1, in _idtcm_set_dpll_hw_tod()
765 err = idtcm_write(idtcm, channel->hw_dpll_n, in _idtcm_set_dpll_hw_tod()
772 static int _idtcm_set_dpll_scsr_tod(struct idtcm_channel *channel, in _idtcm_set_dpll_scsr_tod() argument
777 struct idtcm *idtcm = channel->idtcm; in _idtcm_set_dpll_scsr_tod()
788 err = idtcm_write(idtcm, channel->tod_write, TOD_WRITE, in _idtcm_set_dpll_scsr_tod()
794 err = idtcm_read(idtcm, channel->tod_write, TOD_WRITE_CMD, in _idtcm_set_dpll_scsr_tod()
804 err = idtcm_write(idtcm, channel->tod_write, TOD_WRITE_CMD, in _idtcm_set_dpll_scsr_tod()
815 err = idtcm_read(idtcm, channel->tod_write, TOD_WRITE_CMD, in _idtcm_set_dpll_scsr_tod()
881 static int _idtcm_settime_deprecated(struct idtcm_channel *channel, in _idtcm_settime_deprecated() argument
884 struct idtcm *idtcm = channel->idtcm; in _idtcm_settime_deprecated()
887 err = _idtcm_set_dpll_hw_tod(channel, ts, HW_TOD_WR_TRIG_SEL_MSB); in _idtcm_settime_deprecated()
894 return idtcm_sync_pps_output(channel); in _idtcm_settime_deprecated()
897 static int _idtcm_settime(struct idtcm_channel *channel, in _idtcm_settime() argument
901 return _idtcm_set_dpll_scsr_tod(channel, ts, in _idtcm_settime()
906 static int idtcm_set_phase_pull_in_offset(struct idtcm_channel *channel, in idtcm_set_phase_pull_in_offset() argument
911 struct idtcm *idtcm = channel->idtcm; in idtcm_set_phase_pull_in_offset()
919 err = idtcm_write(idtcm, channel->dpll_phase_pull_in, PULL_IN_OFFSET, in idtcm_set_phase_pull_in_offset()
925 static int idtcm_set_phase_pull_in_slope_limit(struct idtcm_channel *channel, in idtcm_set_phase_pull_in_slope_limit() argument
930 struct idtcm *idtcm = channel->idtcm; in idtcm_set_phase_pull_in_slope_limit()
941 err = idtcm_write(idtcm, channel->dpll_phase_pull_in, in idtcm_set_phase_pull_in_slope_limit()
947 static int idtcm_start_phase_pull_in(struct idtcm_channel *channel) in idtcm_start_phase_pull_in() argument
950 struct idtcm *idtcm = channel->idtcm; in idtcm_start_phase_pull_in()
953 err = idtcm_read(idtcm, channel->dpll_phase_pull_in, PULL_IN_CTRL, in idtcm_start_phase_pull_in()
960 err = idtcm_write(idtcm, channel->dpll_phase_pull_in, in idtcm_start_phase_pull_in()
969 static int do_phase_pull_in_fw(struct idtcm_channel *channel, in do_phase_pull_in_fw() argument
975 err = idtcm_set_phase_pull_in_offset(channel, -offset_ns); in do_phase_pull_in_fw()
979 err = idtcm_set_phase_pull_in_slope_limit(channel, max_ffo_ppb); in do_phase_pull_in_fw()
983 err = idtcm_start_phase_pull_in(channel); in do_phase_pull_in_fw()
988 static int set_tod_write_overhead(struct idtcm_channel *channel) in set_tod_write_overhead() argument
990 struct idtcm *idtcm = channel->idtcm; in set_tod_write_overhead()
1002 idtcm_write(idtcm, channel->hw_dpll_n, HW_DPLL_TOD_OVR__0, in set_tod_write_overhead()
1008 err = idtcm_write(idtcm, channel->hw_dpll_n, in set_tod_write_overhead()
1032 static int _idtcm_adjtime_deprecated(struct idtcm_channel *channel, s64 delta) in _idtcm_adjtime_deprecated() argument
1035 struct idtcm *idtcm = channel->idtcm; in _idtcm_adjtime_deprecated()
1040 err = channel->do_phase_pull_in(channel, delta, 0); in _idtcm_adjtime_deprecated()
1044 err = set_tod_write_overhead(channel); in _idtcm_adjtime_deprecated()
1048 err = _idtcm_gettime_immediate(channel, &ts); in _idtcm_adjtime_deprecated()
1057 err = _idtcm_settime_deprecated(channel, &ts); in _idtcm_adjtime_deprecated()
1152 SET_U16_LSB(idtcm->channel[0].output_mask, val); in set_pll_output_mask()
1155 SET_U16_MSB(idtcm->channel[0].output_mask, val); in set_pll_output_mask()
1158 SET_U16_LSB(idtcm->channel[1].output_mask, val); in set_pll_output_mask()
1161 SET_U16_MSB(idtcm->channel[1].output_mask, val); in set_pll_output_mask()
1164 SET_U16_LSB(idtcm->channel[2].output_mask, val); in set_pll_output_mask()
1167 SET_U16_MSB(idtcm->channel[2].output_mask, val); in set_pll_output_mask()
1170 SET_U16_LSB(idtcm->channel[3].output_mask, val); in set_pll_output_mask()
1173 SET_U16_MSB(idtcm->channel[3].output_mask, val); in set_pll_output_mask()
1195 idtcm->channel[index].pll = pll; in set_tod_ptp_pll()
1248 i, idtcm->channel[i].pll, in display_pll_and_masks()
1249 idtcm->channel[i].output_mask); in display_pll_and_masks()
1327 static int idtcm_output_enable(struct idtcm_channel *channel, in idtcm_output_enable() argument
1330 struct idtcm *idtcm = channel->idtcm; in idtcm_output_enable()
1355 static int idtcm_perout_enable(struct idtcm_channel *channel, in idtcm_perout_enable() argument
1359 struct idtcm *idtcm = channel->idtcm; in idtcm_perout_enable()
1363 err = idtcm_output_enable(channel, enable, perout->index); in idtcm_perout_enable()
1371 return _idtcm_settime(channel, &ts, SCSR_TOD_WR_TYPE_SEL_DELTA_PLUS); in idtcm_perout_enable()
1374 static int idtcm_get_pll_mode(struct idtcm_channel *channel, in idtcm_get_pll_mode() argument
1377 struct idtcm *idtcm = channel->idtcm; in idtcm_get_pll_mode()
1381 err = idtcm_read(idtcm, channel->dpll_n, in idtcm_get_pll_mode()
1392 static int idtcm_set_pll_mode(struct idtcm_channel *channel, in idtcm_set_pll_mode() argument
1395 struct idtcm *idtcm = channel->idtcm; in idtcm_set_pll_mode()
1399 err = idtcm_read(idtcm, channel->dpll_n, in idtcm_set_pll_mode()
1409 err = idtcm_write(idtcm, channel->dpll_n, in idtcm_set_pll_mode()
1415 static int idtcm_get_manual_reference(struct idtcm_channel *channel, in idtcm_get_manual_reference() argument
1418 struct idtcm *idtcm = channel->idtcm; in idtcm_get_manual_reference()
1422 err = idtcm_read(idtcm, channel->dpll_ctrl_n, in idtcm_get_manual_reference()
1435 static int idtcm_set_manual_reference(struct idtcm_channel *channel, in idtcm_set_manual_reference() argument
1438 struct idtcm *idtcm = channel->idtcm; in idtcm_set_manual_reference()
1442 err = idtcm_read(idtcm, channel->dpll_ctrl_n, in idtcm_set_manual_reference()
1452 err = idtcm_write(idtcm, channel->dpll_ctrl_n, in idtcm_set_manual_reference()
1459 static int configure_dpll_mode_write_frequency(struct idtcm_channel *channel) in configure_dpll_mode_write_frequency() argument
1461 struct idtcm *idtcm = channel->idtcm; in configure_dpll_mode_write_frequency()
1464 err = idtcm_set_pll_mode(channel, PLL_MODE_WRITE_FREQUENCY); in configure_dpll_mode_write_frequency()
1469 channel->mode = PTP_PLL_MODE_WRITE_FREQUENCY; in configure_dpll_mode_write_frequency()
1474 static int configure_dpll_mode_write_phase(struct idtcm_channel *channel) in configure_dpll_mode_write_phase() argument
1476 struct idtcm *idtcm = channel->idtcm; in configure_dpll_mode_write_phase()
1479 err = idtcm_set_pll_mode(channel, PLL_MODE_WRITE_PHASE); in configure_dpll_mode_write_phase()
1484 channel->mode = PTP_PLL_MODE_WRITE_PHASE; in configure_dpll_mode_write_phase()
1489 static int configure_manual_reference_write_frequency(struct idtcm_channel *channel) in configure_manual_reference_write_frequency() argument
1491 struct idtcm *idtcm = channel->idtcm; in configure_manual_reference_write_frequency()
1494 err = idtcm_set_manual_reference(channel, MANU_REF_WRITE_FREQUENCY); in configure_manual_reference_write_frequency()
1499 channel->mode = PTP_PLL_MODE_WRITE_FREQUENCY; in configure_manual_reference_write_frequency()
1504 static int configure_manual_reference_write_phase(struct idtcm_channel *channel) in configure_manual_reference_write_phase() argument
1506 struct idtcm *idtcm = channel->idtcm; in configure_manual_reference_write_phase()
1509 err = idtcm_set_manual_reference(channel, MANU_REF_WRITE_PHASE); in configure_manual_reference_write_phase()
1514 channel->mode = PTP_PLL_MODE_WRITE_PHASE; in configure_manual_reference_write_phase()
1519 static int idtcm_stop_phase_pull_in(struct idtcm_channel *channel) in idtcm_stop_phase_pull_in() argument
1523 err = _idtcm_adjfine(channel, channel->current_freq_scaled_ppm); in idtcm_stop_phase_pull_in()
1527 channel->phase_pull_in = false; in idtcm_stop_phase_pull_in()
1534 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_work_handler() local
1535 struct idtcm *idtcm = channel->idtcm; in idtcm_work_handler()
1539 (void)idtcm_stop_phase_pull_in(channel); in idtcm_work_handler()
1565 static int do_phase_pull_in_sw(struct idtcm_channel *channel, in do_phase_pull_in_sw() argument
1569 s32 current_ppm = channel->current_freq_scaled_ppm; in do_phase_pull_in_sw()
1594 err = _idtcm_adjfine(channel, delta_ppm); in do_phase_pull_in_sw()
1600 ptp_schedule_worker(channel->ptp_clock, in do_phase_pull_in_sw()
1603 channel->phase_pull_in = true; in do_phase_pull_in_sw()
1608 static int initialize_operating_mode_with_manual_reference(struct idtcm_channel *channel, in initialize_operating_mode_with_manual_reference() argument
1611 struct idtcm *idtcm = channel->idtcm; in initialize_operating_mode_with_manual_reference()
1613 channel->mode = PTP_PLL_MODE_UNSUPPORTED; in initialize_operating_mode_with_manual_reference()
1614 channel->configure_write_frequency = configure_manual_reference_write_frequency; in initialize_operating_mode_with_manual_reference()
1615 channel->configure_write_phase = configure_manual_reference_write_phase; in initialize_operating_mode_with_manual_reference()
1616 channel->do_phase_pull_in = do_phase_pull_in_sw; in initialize_operating_mode_with_manual_reference()
1620 channel->mode = PTP_PLL_MODE_WRITE_PHASE; in initialize_operating_mode_with_manual_reference()
1623 channel->mode = PTP_PLL_MODE_WRITE_FREQUENCY; in initialize_operating_mode_with_manual_reference()
1633 static int initialize_operating_mode_with_pll_mode(struct idtcm_channel *channel, in initialize_operating_mode_with_pll_mode() argument
1636 struct idtcm *idtcm = channel->idtcm; in initialize_operating_mode_with_pll_mode()
1639 channel->mode = PTP_PLL_MODE_UNSUPPORTED; in initialize_operating_mode_with_pll_mode()
1640 channel->configure_write_frequency = configure_dpll_mode_write_frequency; in initialize_operating_mode_with_pll_mode()
1641 channel->configure_write_phase = configure_dpll_mode_write_phase; in initialize_operating_mode_with_pll_mode()
1642 channel->do_phase_pull_in = do_phase_pull_in_fw; in initialize_operating_mode_with_pll_mode()
1646 channel->mode = PTP_PLL_MODE_WRITE_PHASE; in initialize_operating_mode_with_pll_mode()
1649 channel->mode = PTP_PLL_MODE_WRITE_FREQUENCY; in initialize_operating_mode_with_pll_mode()
1660 static int initialize_dco_operating_mode(struct idtcm_channel *channel) in initialize_dco_operating_mode() argument
1664 struct idtcm *idtcm = channel->idtcm; in initialize_dco_operating_mode()
1667 channel->mode = PTP_PLL_MODE_UNSUPPORTED; in initialize_dco_operating_mode()
1669 err = idtcm_get_pll_mode(channel, &mode); in initialize_dco_operating_mode()
1676 err = idtcm_get_manual_reference(channel, &ref); in initialize_dco_operating_mode()
1681 err = initialize_operating_mode_with_manual_reference(channel, ref); in initialize_dco_operating_mode()
1683 err = initialize_operating_mode_with_pll_mode(channel, mode); in initialize_dco_operating_mode()
1686 if (channel->mode == PTP_PLL_MODE_WRITE_PHASE) in initialize_dco_operating_mode()
1687 channel->configure_write_frequency(channel); in initialize_dco_operating_mode()
1697 * @channel: channel
1704 static int _idtcm_adjphase(struct idtcm_channel *channel, s32 delta_ns) in _idtcm_adjphase() argument
1706 struct idtcm *idtcm = channel->idtcm; in _idtcm_adjphase()
1713 if (channel->mode != PTP_PLL_MODE_WRITE_PHASE) { in _idtcm_adjphase()
1714 err = channel->configure_write_phase(channel); in _idtcm_adjphase()
1738 err = idtcm_write(idtcm, channel->dpll_phase, DPLL_WR_PHASE, in _idtcm_adjphase()
1744 static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm) in _idtcm_adjfine() argument
1746 struct idtcm *idtcm = channel->idtcm; in _idtcm_adjfine()
1752 if (channel->mode != PTP_PLL_MODE_WRITE_FREQUENCY) { in _idtcm_adjfine()
1753 err = channel->configure_write_frequency(channel); in _idtcm_adjfine()
1782 err = idtcm_write(idtcm, channel->dpll_freq, DPLL_WR_FREQ, in _idtcm_adjfine()
1790 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_gettime() local
1791 struct idtcm *idtcm = channel->idtcm; in idtcm_gettime()
1795 err = _idtcm_gettime_immediate(channel, ts); in idtcm_gettime()
1808 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_settime_deprecated() local
1809 struct idtcm *idtcm = channel->idtcm; in idtcm_settime_deprecated()
1813 err = _idtcm_settime_deprecated(channel, ts); in idtcm_settime_deprecated()
1826 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_settime() local
1827 struct idtcm *idtcm = channel->idtcm; in idtcm_settime()
1831 err = _idtcm_settime(channel, ts, SCSR_TOD_WR_TYPE_SEL_ABSOLUTE); in idtcm_settime()
1843 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_adjtime_deprecated() local
1844 struct idtcm *idtcm = channel->idtcm; in idtcm_adjtime_deprecated()
1848 err = _idtcm_adjtime_deprecated(channel, delta); in idtcm_adjtime_deprecated()
1860 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_adjtime() local
1861 struct idtcm *idtcm = channel->idtcm; in idtcm_adjtime()
1866 if (channel->phase_pull_in == true) in idtcm_adjtime()
1872 err = channel->do_phase_pull_in(channel, delta, 0); in idtcm_adjtime()
1881 err = _idtcm_settime(channel, &ts, type); in idtcm_adjtime()
1895 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_adjphase() local
1896 struct idtcm *idtcm = channel->idtcm; in idtcm_adjphase()
1900 err = _idtcm_adjphase(channel, delta); in idtcm_adjphase()
1912 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_adjfine() local
1913 struct idtcm *idtcm = channel->idtcm; in idtcm_adjfine()
1916 if (channel->phase_pull_in == true) in idtcm_adjfine()
1919 if (scaled_ppm == channel->current_freq_scaled_ppm) in idtcm_adjfine()
1923 err = _idtcm_adjfine(channel, scaled_ppm); in idtcm_adjfine()
1930 channel->current_freq_scaled_ppm = scaled_ppm; in idtcm_adjfine()
1938 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_enable() local
1939 struct idtcm *idtcm = channel->idtcm; in idtcm_enable()
1947 err = idtcm_perout_enable(channel, &rq->perout, false); in idtcm_enable()
1953 err = idtcm_perout_enable(channel, &rq->perout, true); in idtcm_enable()
1956 err = idtcm_extts_enable(channel, rq, on); in idtcm_enable()
1965 dev_err(channel->idtcm->dev, in idtcm_enable()
1971 static int idtcm_enable_tod(struct idtcm_channel *channel) in idtcm_enable_tod() argument
1973 struct idtcm *idtcm = channel->idtcm; in idtcm_enable_tod()
1982 err = idtcm_read(idtcm, channel->tod_n, tod_cfg, &cfg, sizeof(cfg)); in idtcm_enable_tod()
1988 err = idtcm_write(idtcm, channel->tod_n, tod_cfg, &cfg, sizeof(cfg)); in idtcm_enable_tod()
1993 return _idtcm_settime_deprecated(channel, &ts); in idtcm_enable_tod()
1995 return _idtcm_settime(channel, &ts, in idtcm_enable_tod()
2076 static int configure_channel_pll(struct idtcm_channel *channel) in configure_channel_pll() argument
2078 struct idtcm *idtcm = channel->idtcm; in configure_channel_pll()
2081 switch (channel->pll) { in configure_channel_pll()
2083 channel->dpll_freq = DPLL_FREQ_0; in configure_channel_pll()
2084 channel->dpll_n = DPLL_0; in configure_channel_pll()
2085 channel->hw_dpll_n = HW_DPLL_0; in configure_channel_pll()
2086 channel->dpll_phase = DPLL_PHASE_0; in configure_channel_pll()
2087 channel->dpll_ctrl_n = DPLL_CTRL_0; in configure_channel_pll()
2088 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_0; in configure_channel_pll()
2091 channel->dpll_freq = DPLL_FREQ_1; in configure_channel_pll()
2092 channel->dpll_n = DPLL_1; in configure_channel_pll()
2093 channel->hw_dpll_n = HW_DPLL_1; in configure_channel_pll()
2094 channel->dpll_phase = DPLL_PHASE_1; in configure_channel_pll()
2095 channel->dpll_ctrl_n = DPLL_CTRL_1; in configure_channel_pll()
2096 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_1; in configure_channel_pll()
2099 channel->dpll_freq = DPLL_FREQ_2; in configure_channel_pll()
2100 channel->dpll_n = IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_2); in configure_channel_pll()
2101 channel->hw_dpll_n = HW_DPLL_2; in configure_channel_pll()
2102 channel->dpll_phase = DPLL_PHASE_2; in configure_channel_pll()
2103 channel->dpll_ctrl_n = DPLL_CTRL_2; in configure_channel_pll()
2104 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_2; in configure_channel_pll()
2107 channel->dpll_freq = DPLL_FREQ_3; in configure_channel_pll()
2108 channel->dpll_n = DPLL_3; in configure_channel_pll()
2109 channel->hw_dpll_n = HW_DPLL_3; in configure_channel_pll()
2110 channel->dpll_phase = DPLL_PHASE_3; in configure_channel_pll()
2111 channel->dpll_ctrl_n = DPLL_CTRL_3; in configure_channel_pll()
2112 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_3; in configure_channel_pll()
2115 channel->dpll_freq = DPLL_FREQ_4; in configure_channel_pll()
2116 channel->dpll_n = IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_4); in configure_channel_pll()
2117 channel->hw_dpll_n = HW_DPLL_4; in configure_channel_pll()
2118 channel->dpll_phase = DPLL_PHASE_4; in configure_channel_pll()
2119 channel->dpll_ctrl_n = DPLL_CTRL_4; in configure_channel_pll()
2120 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_4; in configure_channel_pll()
2123 channel->dpll_freq = DPLL_FREQ_5; in configure_channel_pll()
2124 channel->dpll_n = DPLL_5; in configure_channel_pll()
2125 channel->hw_dpll_n = HW_DPLL_5; in configure_channel_pll()
2126 channel->dpll_phase = DPLL_PHASE_5; in configure_channel_pll()
2127 channel->dpll_ctrl_n = DPLL_CTRL_5; in configure_channel_pll()
2128 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_5; in configure_channel_pll()
2131 channel->dpll_freq = DPLL_FREQ_6; in configure_channel_pll()
2132 channel->dpll_n = IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_6); in configure_channel_pll()
2133 channel->hw_dpll_n = HW_DPLL_6; in configure_channel_pll()
2134 channel->dpll_phase = DPLL_PHASE_6; in configure_channel_pll()
2135 channel->dpll_ctrl_n = DPLL_CTRL_6; in configure_channel_pll()
2136 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_6; in configure_channel_pll()
2139 channel->dpll_freq = DPLL_FREQ_7; in configure_channel_pll()
2140 channel->dpll_n = DPLL_7; in configure_channel_pll()
2141 channel->hw_dpll_n = HW_DPLL_7; in configure_channel_pll()
2142 channel->dpll_phase = DPLL_PHASE_7; in configure_channel_pll()
2143 channel->dpll_ctrl_n = DPLL_CTRL_7; in configure_channel_pll()
2144 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_7; in configure_channel_pll()
2157 static u32 idtcm_get_dco_delay(struct idtcm_channel *channel) in idtcm_get_dco_delay() argument
2159 struct idtcm *idtcm = channel->idtcm; in idtcm_get_dco_delay()
2167 err = idtcm_read(idtcm, channel->dpll_ctrl_n, in idtcm_get_dco_delay()
2172 err = idtcm_read(idtcm, channel->dpll_ctrl_n, in idtcm_get_dco_delay()
2191 static int configure_channel_tod(struct idtcm_channel *channel, u32 index) in configure_channel_tod() argument
2193 enum fw_version fw_ver = channel->idtcm->fw_ver; in configure_channel_tod()
2198 channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_0); in configure_channel_tod()
2199 channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_0); in configure_channel_tod()
2200 channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_0); in configure_channel_tod()
2201 channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_0); in configure_channel_tod()
2202 channel->sync_src = SYNC_SOURCE_DPLL0_TOD_PPS; in configure_channel_tod()
2205 channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_1); in configure_channel_tod()
2206 channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_1); in configure_channel_tod()
2207 channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_1); in configure_channel_tod()
2208 channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_1); in configure_channel_tod()
2209 channel->sync_src = SYNC_SOURCE_DPLL1_TOD_PPS; in configure_channel_tod()
2212 channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_2); in configure_channel_tod()
2213 channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_2); in configure_channel_tod()
2214 channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_2); in configure_channel_tod()
2215 channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_2); in configure_channel_tod()
2216 channel->sync_src = SYNC_SOURCE_DPLL2_TOD_PPS; in configure_channel_tod()
2219 channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_3); in configure_channel_tod()
2220 channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_3); in configure_channel_tod()
2221 channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_3); in configure_channel_tod()
2222 channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_3); in configure_channel_tod()
2223 channel->sync_src = SYNC_SOURCE_DPLL3_TOD_PPS; in configure_channel_tod()
2234 struct idtcm_channel *channel; in idtcm_enable_channel() local
2241 channel = &idtcm->channel[index]; in idtcm_enable_channel()
2243 channel->idtcm = idtcm; in idtcm_enable_channel()
2244 channel->current_freq_scaled_ppm = 0; in idtcm_enable_channel()
2247 err = configure_channel_pll(channel); in idtcm_enable_channel()
2252 err = configure_channel_tod(channel, index); in idtcm_enable_channel()
2257 channel->caps = idtcm_caps_deprecated; in idtcm_enable_channel()
2259 channel->caps = idtcm_caps; in idtcm_enable_channel()
2261 snprintf(channel->caps.name, sizeof(channel->caps.name), in idtcm_enable_channel()
2264 channel->caps.pin_config = pin_config[index]; in idtcm_enable_channel()
2266 for (i = 0; i < channel->caps.n_pins; ++i) { in idtcm_enable_channel()
2267 struct ptp_pin_desc *ppd = &channel->caps.pin_config[i]; in idtcm_enable_channel()
2275 err = initialize_dco_operating_mode(channel); in idtcm_enable_channel()
2279 err = idtcm_enable_tod(channel); in idtcm_enable_channel()
2286 channel->dco_delay = idtcm_get_dco_delay(channel); in idtcm_enable_channel()
2288 channel->ptp_clock = ptp_clock_register(&channel->caps, NULL); in idtcm_enable_channel()
2290 if (IS_ERR(channel->ptp_clock)) { in idtcm_enable_channel()
2291 err = PTR_ERR(channel->ptp_clock); in idtcm_enable_channel()
2292 channel->ptp_clock = NULL; in idtcm_enable_channel()
2296 if (!channel->ptp_clock) in idtcm_enable_channel()
2300 index, channel->ptp_clock->index); in idtcm_enable_channel()
2307 struct idtcm_channel *channel; in idtcm_enable_extts_channel() local
2313 channel = &idtcm->channel[index]; in idtcm_enable_extts_channel()
2314 channel->idtcm = idtcm; in idtcm_enable_extts_channel()
2317 err = configure_channel_tod(channel, index); in idtcm_enable_extts_channel()
2321 channel->idtcm = idtcm; in idtcm_enable_extts_channel()
2329 struct idtcm_channel *channel; in idtcm_extts_check() local
2353 channel = &idtcm->channel[i]; in idtcm_extts_check()
2354 arm_tod_read_trig_sel_refclk(channel, channel->refn); in idtcm_extts_check()
2369 struct idtcm_channel *channel; in ptp_clock_unregister_all() local
2372 channel = &idtcm->channel[i]; in ptp_clock_unregister_all()
2373 if (channel->ptp_clock) in ptp_clock_unregister_all()
2374 ptp_clock_unregister(channel->ptp_clock); in ptp_clock_unregister_all()
2383 idtcm->channel[0].tod = 0; in set_default_masks()
2384 idtcm->channel[1].tod = 1; in set_default_masks()
2385 idtcm->channel[2].tod = 2; in set_default_masks()
2386 idtcm->channel[3].tod = 3; in set_default_masks()
2388 idtcm->channel[0].pll = DEFAULT_TOD0_PTP_PLL; in set_default_masks()
2389 idtcm->channel[1].pll = DEFAULT_TOD1_PTP_PLL; in set_default_masks()
2390 idtcm->channel[2].pll = DEFAULT_TOD2_PTP_PLL; in set_default_masks()
2391 idtcm->channel[3].pll = DEFAULT_TOD3_PTP_PLL; in set_default_masks()
2393 idtcm->channel[0].output_mask = DEFAULT_OUTPUT_MASK_PLL0; in set_default_masks()
2394 idtcm->channel[1].output_mask = DEFAULT_OUTPUT_MASK_PLL1; in set_default_masks()
2395 idtcm->channel[2].output_mask = DEFAULT_OUTPUT_MASK_PLL2; in set_default_masks()
2396 idtcm->channel[3].output_mask = DEFAULT_OUTPUT_MASK_PLL3; in set_default_masks()