Lines Matching refs: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()
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()
1713 static int _idtcm_adjphase(struct idtcm_channel *channel, s32 delta_ns) in _idtcm_adjphase() argument
1715 struct idtcm *idtcm = channel->idtcm; in _idtcm_adjphase()
1721 if (channel->mode != PTP_PLL_MODE_WRITE_PHASE) { in _idtcm_adjphase()
1722 err = channel->configure_write_phase(channel); in _idtcm_adjphase()
1734 err = idtcm_write(idtcm, channel->dpll_phase, DPLL_WR_PHASE, in _idtcm_adjphase()
1740 static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm) in _idtcm_adjfine() argument
1742 struct idtcm *idtcm = channel->idtcm; in _idtcm_adjfine()
1748 if (channel->mode != PTP_PLL_MODE_WRITE_FREQUENCY) { in _idtcm_adjfine()
1749 err = channel->configure_write_frequency(channel); in _idtcm_adjfine()
1778 err = idtcm_write(idtcm, channel->dpll_freq, DPLL_WR_FREQ, in _idtcm_adjfine()
1786 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_gettime() local
1787 struct idtcm *idtcm = channel->idtcm; in idtcm_gettime()
1791 err = _idtcm_gettime_immediate(channel, ts); in idtcm_gettime()
1804 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_settime_deprecated() local
1805 struct idtcm *idtcm = channel->idtcm; in idtcm_settime_deprecated()
1809 err = _idtcm_settime_deprecated(channel, ts); in idtcm_settime_deprecated()
1822 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_settime() local
1823 struct idtcm *idtcm = channel->idtcm; in idtcm_settime()
1827 err = _idtcm_settime(channel, ts, SCSR_TOD_WR_TYPE_SEL_ABSOLUTE); in idtcm_settime()
1839 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_adjtime_deprecated() local
1840 struct idtcm *idtcm = channel->idtcm; in idtcm_adjtime_deprecated()
1844 err = _idtcm_adjtime_deprecated(channel, delta); in idtcm_adjtime_deprecated()
1856 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_adjtime() local
1857 struct idtcm *idtcm = channel->idtcm; in idtcm_adjtime()
1862 if (channel->phase_pull_in == true) in idtcm_adjtime()
1868 err = channel->do_phase_pull_in(channel, delta, 0); in idtcm_adjtime()
1877 err = _idtcm_settime(channel, &ts, type); in idtcm_adjtime()
1891 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_adjphase() local
1892 struct idtcm *idtcm = channel->idtcm; in idtcm_adjphase()
1896 err = _idtcm_adjphase(channel, delta); in idtcm_adjphase()
1908 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_adjfine() local
1909 struct idtcm *idtcm = channel->idtcm; in idtcm_adjfine()
1912 if (channel->phase_pull_in == true) in idtcm_adjfine()
1915 if (scaled_ppm == channel->current_freq_scaled_ppm) in idtcm_adjfine()
1919 err = _idtcm_adjfine(channel, scaled_ppm); in idtcm_adjfine()
1926 channel->current_freq_scaled_ppm = scaled_ppm; in idtcm_adjfine()
1934 struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps); in idtcm_enable() local
1935 struct idtcm *idtcm = channel->idtcm; in idtcm_enable()
1943 err = idtcm_perout_enable(channel, &rq->perout, false); in idtcm_enable()
1949 err = idtcm_perout_enable(channel, &rq->perout, true); in idtcm_enable()
1952 err = idtcm_extts_enable(channel, rq, on); in idtcm_enable()
1961 dev_err(channel->idtcm->dev, in idtcm_enable()
1967 static int idtcm_enable_tod(struct idtcm_channel *channel) in idtcm_enable_tod() argument
1969 struct idtcm *idtcm = channel->idtcm; in idtcm_enable_tod()
1978 err = idtcm_read(idtcm, channel->tod_n, tod_cfg, &cfg, sizeof(cfg)); in idtcm_enable_tod()
1984 err = idtcm_write(idtcm, channel->tod_n, tod_cfg, &cfg, sizeof(cfg)); in idtcm_enable_tod()
1989 return _idtcm_settime_deprecated(channel, &ts); in idtcm_enable_tod()
1991 return _idtcm_settime(channel, &ts, in idtcm_enable_tod()
2074 static int configure_channel_pll(struct idtcm_channel *channel) in configure_channel_pll() argument
2076 struct idtcm *idtcm = channel->idtcm; in configure_channel_pll()
2079 switch (channel->pll) { in configure_channel_pll()
2081 channel->dpll_freq = DPLL_FREQ_0; in configure_channel_pll()
2082 channel->dpll_n = DPLL_0; in configure_channel_pll()
2083 channel->hw_dpll_n = HW_DPLL_0; in configure_channel_pll()
2084 channel->dpll_phase = DPLL_PHASE_0; in configure_channel_pll()
2085 channel->dpll_ctrl_n = DPLL_CTRL_0; in configure_channel_pll()
2086 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_0; in configure_channel_pll()
2089 channel->dpll_freq = DPLL_FREQ_1; in configure_channel_pll()
2090 channel->dpll_n = DPLL_1; in configure_channel_pll()
2091 channel->hw_dpll_n = HW_DPLL_1; in configure_channel_pll()
2092 channel->dpll_phase = DPLL_PHASE_1; in configure_channel_pll()
2093 channel->dpll_ctrl_n = DPLL_CTRL_1; in configure_channel_pll()
2094 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_1; in configure_channel_pll()
2097 channel->dpll_freq = DPLL_FREQ_2; in configure_channel_pll()
2098 channel->dpll_n = IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_2); in configure_channel_pll()
2099 channel->hw_dpll_n = HW_DPLL_2; in configure_channel_pll()
2100 channel->dpll_phase = DPLL_PHASE_2; in configure_channel_pll()
2101 channel->dpll_ctrl_n = DPLL_CTRL_2; in configure_channel_pll()
2102 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_2; in configure_channel_pll()
2105 channel->dpll_freq = DPLL_FREQ_3; in configure_channel_pll()
2106 channel->dpll_n = DPLL_3; in configure_channel_pll()
2107 channel->hw_dpll_n = HW_DPLL_3; in configure_channel_pll()
2108 channel->dpll_phase = DPLL_PHASE_3; in configure_channel_pll()
2109 channel->dpll_ctrl_n = DPLL_CTRL_3; in configure_channel_pll()
2110 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_3; in configure_channel_pll()
2113 channel->dpll_freq = DPLL_FREQ_4; in configure_channel_pll()
2114 channel->dpll_n = IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_4); in configure_channel_pll()
2115 channel->hw_dpll_n = HW_DPLL_4; in configure_channel_pll()
2116 channel->dpll_phase = DPLL_PHASE_4; in configure_channel_pll()
2117 channel->dpll_ctrl_n = DPLL_CTRL_4; in configure_channel_pll()
2118 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_4; in configure_channel_pll()
2121 channel->dpll_freq = DPLL_FREQ_5; in configure_channel_pll()
2122 channel->dpll_n = DPLL_5; in configure_channel_pll()
2123 channel->hw_dpll_n = HW_DPLL_5; in configure_channel_pll()
2124 channel->dpll_phase = DPLL_PHASE_5; in configure_channel_pll()
2125 channel->dpll_ctrl_n = DPLL_CTRL_5; in configure_channel_pll()
2126 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_5; in configure_channel_pll()
2129 channel->dpll_freq = DPLL_FREQ_6; in configure_channel_pll()
2130 channel->dpll_n = IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_6); in configure_channel_pll()
2131 channel->hw_dpll_n = HW_DPLL_6; in configure_channel_pll()
2132 channel->dpll_phase = DPLL_PHASE_6; in configure_channel_pll()
2133 channel->dpll_ctrl_n = DPLL_CTRL_6; in configure_channel_pll()
2134 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_6; in configure_channel_pll()
2137 channel->dpll_freq = DPLL_FREQ_7; in configure_channel_pll()
2138 channel->dpll_n = DPLL_7; in configure_channel_pll()
2139 channel->hw_dpll_n = HW_DPLL_7; in configure_channel_pll()
2140 channel->dpll_phase = DPLL_PHASE_7; in configure_channel_pll()
2141 channel->dpll_ctrl_n = DPLL_CTRL_7; in configure_channel_pll()
2142 channel->dpll_phase_pull_in = DPLL_PHASE_PULL_IN_7; in configure_channel_pll()
2155 static u32 idtcm_get_dco_delay(struct idtcm_channel *channel) in idtcm_get_dco_delay() argument
2157 struct idtcm *idtcm = channel->idtcm; in idtcm_get_dco_delay()
2165 err = idtcm_read(idtcm, channel->dpll_ctrl_n, in idtcm_get_dco_delay()
2170 err = idtcm_read(idtcm, channel->dpll_ctrl_n, in idtcm_get_dco_delay()
2189 static int configure_channel_tod(struct idtcm_channel *channel, u32 index) in configure_channel_tod() argument
2191 enum fw_version fw_ver = channel->idtcm->fw_ver; in configure_channel_tod()
2196 channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_0); in configure_channel_tod()
2197 channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_0); in configure_channel_tod()
2198 channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_0); in configure_channel_tod()
2199 channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_0); in configure_channel_tod()
2200 channel->sync_src = SYNC_SOURCE_DPLL0_TOD_PPS; in configure_channel_tod()
2203 channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_1); in configure_channel_tod()
2204 channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_1); in configure_channel_tod()
2205 channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_1); in configure_channel_tod()
2206 channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_1); in configure_channel_tod()
2207 channel->sync_src = SYNC_SOURCE_DPLL1_TOD_PPS; in configure_channel_tod()
2210 channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_2); in configure_channel_tod()
2211 channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_2); in configure_channel_tod()
2212 channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_2); in configure_channel_tod()
2213 channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_2); in configure_channel_tod()
2214 channel->sync_src = SYNC_SOURCE_DPLL2_TOD_PPS; in configure_channel_tod()
2217 channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_3); in configure_channel_tod()
2218 channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_3); in configure_channel_tod()
2219 channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_3); in configure_channel_tod()
2220 channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_3); in configure_channel_tod()
2221 channel->sync_src = SYNC_SOURCE_DPLL3_TOD_PPS; in configure_channel_tod()
2232 struct idtcm_channel *channel; in idtcm_enable_channel() local
2239 channel = &idtcm->channel[index]; in idtcm_enable_channel()
2241 channel->idtcm = idtcm; in idtcm_enable_channel()
2242 channel->current_freq_scaled_ppm = 0; in idtcm_enable_channel()
2245 err = configure_channel_pll(channel); in idtcm_enable_channel()
2250 err = configure_channel_tod(channel, index); in idtcm_enable_channel()
2255 channel->caps = idtcm_caps_deprecated; in idtcm_enable_channel()
2257 channel->caps = idtcm_caps; in idtcm_enable_channel()
2259 snprintf(channel->caps.name, sizeof(channel->caps.name), in idtcm_enable_channel()
2262 channel->caps.pin_config = pin_config[index]; in idtcm_enable_channel()
2264 for (i = 0; i < channel->caps.n_pins; ++i) { in idtcm_enable_channel()
2265 struct ptp_pin_desc *ppd = &channel->caps.pin_config[i]; in idtcm_enable_channel()
2273 err = initialize_dco_operating_mode(channel); in idtcm_enable_channel()
2277 err = idtcm_enable_tod(channel); in idtcm_enable_channel()
2284 channel->dco_delay = idtcm_get_dco_delay(channel); in idtcm_enable_channel()
2286 channel->ptp_clock = ptp_clock_register(&channel->caps, NULL); in idtcm_enable_channel()
2288 if (IS_ERR(channel->ptp_clock)) { in idtcm_enable_channel()
2289 err = PTR_ERR(channel->ptp_clock); in idtcm_enable_channel()
2290 channel->ptp_clock = NULL; in idtcm_enable_channel()
2294 if (!channel->ptp_clock) in idtcm_enable_channel()
2298 index, channel->ptp_clock->index); in idtcm_enable_channel()
2305 struct idtcm_channel *channel; in idtcm_enable_extts_channel() local
2311 channel = &idtcm->channel[index]; in idtcm_enable_extts_channel()
2312 channel->idtcm = idtcm; in idtcm_enable_extts_channel()
2315 err = configure_channel_tod(channel, index); in idtcm_enable_extts_channel()
2319 channel->idtcm = idtcm; in idtcm_enable_extts_channel()
2327 struct idtcm_channel *channel; in idtcm_extts_check() local
2351 channel = &idtcm->channel[i]; in idtcm_extts_check()
2352 arm_tod_read_trig_sel_refclk(channel, channel->refn); in idtcm_extts_check()
2367 struct idtcm_channel *channel; in ptp_clock_unregister_all() local
2370 channel = &idtcm->channel[i]; in ptp_clock_unregister_all()
2371 if (channel->ptp_clock) in ptp_clock_unregister_all()
2372 ptp_clock_unregister(channel->ptp_clock); in ptp_clock_unregister_all()
2381 idtcm->channel[0].tod = 0; in set_default_masks()
2382 idtcm->channel[1].tod = 1; in set_default_masks()
2383 idtcm->channel[2].tod = 2; in set_default_masks()
2384 idtcm->channel[3].tod = 3; in set_default_masks()
2386 idtcm->channel[0].pll = DEFAULT_TOD0_PTP_PLL; in set_default_masks()
2387 idtcm->channel[1].pll = DEFAULT_TOD1_PTP_PLL; in set_default_masks()
2388 idtcm->channel[2].pll = DEFAULT_TOD2_PTP_PLL; in set_default_masks()
2389 idtcm->channel[3].pll = DEFAULT_TOD3_PTP_PLL; in set_default_masks()
2391 idtcm->channel[0].output_mask = DEFAULT_OUTPUT_MASK_PLL0; in set_default_masks()
2392 idtcm->channel[1].output_mask = DEFAULT_OUTPUT_MASK_PLL1; in set_default_masks()
2393 idtcm->channel[2].output_mask = DEFAULT_OUTPUT_MASK_PLL2; in set_default_masks()
2394 idtcm->channel[3].output_mask = DEFAULT_OUTPUT_MASK_PLL3; in set_default_masks()