Lines Matching full:pf
192 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_set_sma_e810t() local
193 struct ice_hw *hw = &pf->hw; in ice_ptp_set_sma_e810t()
260 * @pf: Board private structure
265 static void ice_ptp_cfg_tx_interrupt(struct ice_pf *pf) in ice_ptp_cfg_tx_interrupt() argument
267 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_tx_interrupt()
271 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_cfg_tx_interrupt()
284 enable = pf->ptp.tstamp_config.tx_type == HWTSTAMP_TX_ON; in ice_ptp_cfg_tx_interrupt()
299 * @pf: The PF pointer to search in
302 static void ice_set_rx_tstamp(struct ice_pf *pf, bool on) in ice_set_rx_tstamp() argument
307 vsi = ice_get_main_vsi(pf); in ice_set_rx_tstamp()
321 * @pf: Board private structure
327 static void ice_ptp_disable_timestamp_mode(struct ice_pf *pf) in ice_ptp_disable_timestamp_mode() argument
329 struct ice_hw *hw = &pf->hw; in ice_ptp_disable_timestamp_mode()
336 ice_set_rx_tstamp(pf, false); in ice_ptp_disable_timestamp_mode()
341 * @pf: Board private structure
346 void ice_ptp_restore_timestamp_mode(struct ice_pf *pf) in ice_ptp_restore_timestamp_mode() argument
348 struct ice_hw *hw = &pf->hw; in ice_ptp_restore_timestamp_mode()
351 ice_ptp_cfg_tx_interrupt(pf); in ice_ptp_restore_timestamp_mode()
353 enable_rx = pf->ptp.tstamp_config.rx_filter == HWTSTAMP_FILTER_ALL; in ice_ptp_restore_timestamp_mode()
354 ice_set_rx_tstamp(pf, enable_rx); in ice_ptp_restore_timestamp_mode()
365 * @pf: Board private structure
370 ice_ptp_read_src_clk_reg(struct ice_pf *pf, struct ptp_system_timestamp *sts) in ice_ptp_read_src_clk_reg() argument
372 struct ice_hw *hw = &pf->hw; in ice_ptp_read_src_clk_reg()
470 * @pf: Board private structure
494 static u64 ice_ptp_extend_40b_ts(struct ice_pf *pf, u64 in_tstamp) in ice_ptp_extend_40b_ts() argument
500 discard_time = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_extend_40b_ts()
502 pf->ptp.tx_hwtstamp_discarded++; in ice_ptp_extend_40b_ts()
506 return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, in ice_ptp_extend_40b_ts()
536 struct ice_pf *pf; in ice_ptp_req_tx_single_tstamp() local
542 pf = ptp_port_to_pf(ptp_port); in ice_ptp_req_tx_single_tstamp()
547 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_req_tx_single_tstamp()
559 /* Write TS index to read to the PF register so the FW can read it */ in ice_ptp_req_tx_single_tstamp()
560 wr32(&pf->hw, PF_SB_ATQBAL, in ice_ptp_req_tx_single_tstamp()
578 struct ice_pf *pf; in ice_ptp_complete_tx_single_tstamp() local
585 pf = ptp_port_to_pf(ptp_port); in ice_ptp_complete_tx_single_tstamp()
589 val = rd32(&pf->hw, PF_SB_ATQBAL); in ice_ptp_complete_tx_single_tstamp()
593 dev_err(ice_pf_to_dev(pf), "Failed to get the Tx tstamp - FW not ready"); in ice_ptp_complete_tx_single_tstamp()
602 raw_tstamp |= (u64)rd32(&pf->hw, PF_SB_ATQBAH); in ice_ptp_complete_tx_single_tstamp()
630 tstamp = ice_ptp_extend_40b_ts(pf, raw_tstamp); in ice_ptp_complete_tx_single_tstamp()
692 struct ice_pf *pf; in ice_ptp_process_tx_tstamp() local
700 pf = ptp_port_to_pf(ptp_port); in ice_ptp_process_tx_tstamp()
701 hw = &pf->hw; in ice_ptp_process_tx_tstamp()
723 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_process_tx_tstamp()
785 tstamp = ice_ptp_extend_40b_ts(pf, raw_tstamp); in ice_ptp_process_tx_tstamp()
798 * @pf: Board private structure
800 static enum ice_tx_tstamp_work ice_ptp_tx_tstamp_owner(struct ice_pf *pf) in ice_ptp_tx_tstamp_owner() argument
805 mutex_lock(&pf->ptp.ports_owner.lock); in ice_ptp_tx_tstamp_owner()
806 list_for_each_entry(port, &pf->ptp.ports_owner.ports, list_member) { in ice_ptp_tx_tstamp_owner()
814 mutex_unlock(&pf->ptp.ports_owner.lock); in ice_ptp_tx_tstamp_owner()
821 err = ice_get_phy_tx_tstamp_ready(&pf->hw, i, &tstamp_ready); in ice_ptp_tx_tstamp_owner()
898 * @pf: Board private structure
904 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
906 struct ice_hw *hw = &pf->hw; in ice_ptp_flush_tx_tracker()
914 dev_dbg(ice_pf_to_dev(pf), "Failed to get the Tx tstamp ready bitmap for block %u, err %d\n", in ice_ptp_flush_tx_tracker()
939 pf->ptp.tx_hwtstamp_flushed++; in ice_ptp_flush_tx_tracker()
969 * @pf: Board private structure
975 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
984 synchronize_irq(pf->oicr_irq.virq); in ice_ptp_release_tx_tracker()
986 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
1002 * @pf: Board private structure
1012 ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) in ice_ptp_init_tx_e82x() argument
1024 * @pf: Board private structure
1027 * Initialize the Tx timestamp tracker for this PF. For E810 devices, each
1031 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
1033 tx->block = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
1047 * @pf: Board specific private structure
1049 * This function updates the system time values which are cached in the PF
1055 * Note that the cached copy in the PF PTP structure is always updated, even
1060 * * -EAGAIN - PF was busy, need to reschedule the update
1062 static int ice_ptp_update_cached_phctime(struct ice_pf *pf) in ice_ptp_update_cached_phctime() argument
1064 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_update_cached_phctime()
1069 update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_update_cached_phctime()
1070 if (pf->ptp.cached_phc_time && in ice_ptp_update_cached_phctime()
1072 unsigned long time_taken = jiffies - pf->ptp.cached_phc_jiffies; in ice_ptp_update_cached_phctime()
1076 pf->ptp.late_cached_phc_updates++; in ice_ptp_update_cached_phctime()
1080 systime = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_update_cached_phctime()
1082 /* Update the cached PHC time stored in the PF structure */ in ice_ptp_update_cached_phctime()
1083 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
1084 WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); in ice_ptp_update_cached_phctime()
1086 if (test_and_set_bit(ICE_CFG_BUSY, pf->state)) in ice_ptp_update_cached_phctime()
1089 ice_for_each_vsi(pf, i) { in ice_ptp_update_cached_phctime()
1090 struct ice_vsi *vsi = pf->vsi[i]; in ice_ptp_update_cached_phctime()
1105 clear_bit(ICE_CFG_BUSY, pf->state); in ice_ptp_update_cached_phctime()
1112 * @pf: Board specific private structure
1116 * timestamps as stale and updates the cached PHC time for both the PF and Rx
1123 static void ice_ptp_reset_cached_phctime(struct ice_pf *pf) in ice_ptp_reset_cached_phctime() argument
1125 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_reset_cached_phctime()
1131 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_reset_cached_phctime()
1141 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, in ice_ptp_reset_cached_phctime()
1150 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1155 * @pf: Board private structure
1165 ice_ptp_read_time(struct ice_pf *pf, struct timespec64 *ts, in ice_ptp_read_time() argument
1168 u64 time_ns = ice_ptp_read_src_clk_reg(pf, sts); in ice_ptp_read_time()
1175 * @pf: Board private structure
1180 static int ice_ptp_write_init(struct ice_pf *pf, struct timespec64 *ts) in ice_ptp_write_init() argument
1183 struct ice_hw *hw = &pf->hw; in ice_ptp_write_init()
1190 * @pf: Board private structure
1196 static int ice_ptp_write_adj(struct ice_pf *pf, s32 adj) in ice_ptp_write_adj() argument
1198 struct ice_hw *hw = &pf->hw; in ice_ptp_write_adj()
1205 * @pf: Board private structure
1212 static u64 ice_base_incval(struct ice_pf *pf) in ice_base_incval() argument
1214 struct ice_hw *hw = &pf->hw; in ice_base_incval()
1224 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
1238 struct ice_pf *pf; in ice_ptp_check_tx_fifo() local
1243 pf = ptp_port_to_pf(port); in ice_ptp_check_tx_fifo()
1244 hw = &pf->hw; in ice_ptp_check_tx_fifo()
1258 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1275 dev_dbg(ice_pf_to_dev(pf), "Try %d, port %d FIFO not empty\n", in ice_ptp_check_tx_fifo()
1279 dev_dbg(ice_pf_to_dev(pf), in ice_ptp_check_tx_fifo()
1308 struct ice_pf *pf; in ice_ptp_wait_for_offsets() local
1314 pf = ptp_port_to_pf(port); in ice_ptp_wait_for_offsets()
1315 hw = &pf->hw; in ice_ptp_wait_for_offsets()
1317 if (ice_is_reset_in_progress(pf->state)) { in ice_ptp_wait_for_offsets()
1319 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1331 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1345 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_stop() local
1347 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_stop()
1359 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
1378 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_restart() local
1380 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_restart()
1410 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0); in ice_ptp_port_phy_restart()
1414 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1424 * @pf: Board private structure
1428 void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) in ice_ptp_link_change() argument
1431 struct ice_hw *hw = &pf->hw; in ice_ptp_link_change()
1433 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_link_change()
1439 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1454 dev_warn(ice_pf_to_dev(pf), "%s: Unknown PHY type\n", __func__); in ice_ptp_link_change()
1460 * @pf: PF private structure
1466 static int ice_ptp_tx_ena_intr(struct ice_pf *pf, bool ena, u32 threshold) in ice_ptp_tx_ena_intr() argument
1468 struct ice_hw *hw = &pf->hw; in ice_ptp_tx_ena_intr()
1497 dev_err(ice_pf_to_dev(pf), "PTP failed in intr ena, err %d\n", in ice_ptp_tx_ena_intr()
1504 * @pf: Board private structure
1506 static void ice_ptp_reset_phy_timestamping(struct ice_pf *pf) in ice_ptp_reset_phy_timestamping() argument
1508 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1513 * @pf: Board private structure
1515 static void ice_ptp_restart_all_phy(struct ice_pf *pf) in ice_ptp_restart_all_phy() argument
1519 list_for_each(entry, &pf->ptp.ports_owner.ports) { in ice_ptp_restart_all_phy()
1539 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjfine() local
1540 struct ice_hw *hw = &pf->hw; in ice_ptp_adjfine()
1544 incval = adjust_by_scaled_ppm(ice_base_incval(pf), scaled_ppm); in ice_ptp_adjfine()
1547 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1557 * @pf: Board private structure
1559 void ice_ptp_extts_event(struct ice_pf *pf) in ice_ptp_extts_event() argument
1562 struct ice_hw *hw = &pf->hw; in ice_ptp_extts_event()
1574 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_event()
1582 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_event()
1583 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_event()
1590 * @pf: Board private structure
1597 ice_ptp_cfg_extts(struct ice_pf *pf, bool ena, unsigned int chan, u32 gpio_pin, in ice_ptp_cfg_extts() argument
1601 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_extts()
1604 if (chan > (unsigned int)pf->ptp.info.n_ext_ts) in ice_ptp_cfg_extts()
1631 pf->ptp.ext_ts_chan |= (1 << chan); in ice_ptp_cfg_extts()
1636 pf->ptp.ext_ts_chan &= ~(1 << chan); in ice_ptp_cfg_extts()
1637 if (!pf->ptp.ext_ts_chan) in ice_ptp_cfg_extts()
1650 * @pf: Board private structure
1658 static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan, in ice_ptp_cfg_clkout() argument
1662 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_clkout()
1680 gpio_pin = pf->ptp.perout_channels[chan].gpio_pin; in ice_ptp_cfg_clkout()
1685 memset(&pf->ptp.perout_channels[chan], 0, in ice_ptp_cfg_clkout()
1697 dev_err(ice_pf_to_dev(pf), "CLK Period must be an even value\n"); in ice_ptp_cfg_clkout()
1707 dev_err(ice_pf_to_dev(pf), "CLK Period must be > %d && < 2^33", in ice_ptp_cfg_clkout()
1715 current_time = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_cfg_clkout()
1745 memcpy(&pf->ptp.perout_channels[chan], config, in ice_ptp_cfg_clkout()
1747 pf->ptp.perout_channels[chan].start_time = phase; in ice_ptp_cfg_clkout()
1752 dev_err(ice_pf_to_dev(pf), "PTP failed to cfg per_clk\n"); in ice_ptp_cfg_clkout()
1758 * @pf: pointer to the PF structure
1764 static void ice_ptp_disable_all_clkout(struct ice_pf *pf) in ice_ptp_disable_all_clkout() argument
1768 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_clkout()
1769 if (pf->ptp.perout_channels[i].ena) in ice_ptp_disable_all_clkout()
1770 ice_ptp_cfg_clkout(pf, i, NULL, false); in ice_ptp_disable_all_clkout()
1775 * @pf: pointer to the PF structure
1781 static void ice_ptp_enable_all_clkout(struct ice_pf *pf) in ice_ptp_enable_all_clkout() argument
1785 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_clkout()
1786 if (pf->ptp.perout_channels[i].ena) in ice_ptp_enable_all_clkout()
1787 ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], in ice_ptp_enable_all_clkout()
1801 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gpio_enable_e810() local
1808 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) in ice_ptp_gpio_enable_e810()
1821 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1838 err = ice_ptp_cfg_clkout(pf, chan, &clk_cfg, true); in ice_ptp_gpio_enable_e810()
1847 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1856 err = ice_ptp_cfg_extts(pf, !!on, chan, gpio_pin, in ice_ptp_gpio_enable_e810()
1875 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gpio_enable_e823() local
1885 err = ice_ptp_cfg_clkout(pf, PPS_CLK_GEN_CHAN, &clk_cfg, true); in ice_ptp_gpio_enable_e823()
1888 err = ice_ptp_cfg_extts(pf, !!on, rq->extts.index, in ice_ptp_gpio_enable_e823()
1912 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gettimex64() local
1913 struct ice_hw *hw = &pf->hw; in ice_ptp_gettimex64()
1916 dev_err(ice_pf_to_dev(pf), "PTP failed to get time\n"); in ice_ptp_gettimex64()
1920 ice_ptp_read_time(pf, ts, sts); in ice_ptp_gettimex64()
1937 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_settime64() local
1939 struct ice_hw *hw = &pf->hw; in ice_ptp_settime64()
1945 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1946 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_settime64()
1954 ice_ptp_disable_all_clkout(pf); in ice_ptp_settime64()
1956 err = ice_ptp_write_init(pf, &ts64); in ice_ptp_settime64()
1960 ice_ptp_reset_cached_phctime(pf); in ice_ptp_settime64()
1963 ice_ptp_enable_all_clkout(pf); in ice_ptp_settime64()
1967 ice_ptp_restart_all_phy(pf); in ice_ptp_settime64()
1970 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
2003 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjtime() local
2004 struct ice_hw *hw = &pf->hw; in ice_ptp_adjtime()
2008 dev = ice_pf_to_dev(pf); in ice_ptp_adjtime()
2025 ice_ptp_disable_all_clkout(pf); in ice_ptp_adjtime()
2027 err = ice_ptp_write_adj(pf, delta); in ice_ptp_adjtime()
2030 ice_ptp_enable_all_clkout(pf); in ice_ptp_adjtime()
2039 ice_ptp_reset_cached_phctime(pf); in ice_ptp_adjtime()
2059 struct ice_pf *pf = (struct ice_pf *)ctx; in ice_ptp_get_syncdevicetime() local
2060 struct ice_hw *hw = &pf->hw; in ice_ptp_get_syncdevicetime()
2077 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
2147 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_getcrosststamp_e82x() local
2150 pf, NULL, cts); in ice_ptp_getcrosststamp_e82x()
2156 * @pf: Board private structure
2161 int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_get_ts_config() argument
2165 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_get_ts_config()
2168 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
2176 * @pf: Board private structure
2180 ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) in ice_ptp_set_timestamp_mode() argument
2184 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_OFF; in ice_ptp_set_timestamp_mode()
2187 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_ON; in ice_ptp_set_timestamp_mode()
2195 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ice_ptp_set_timestamp_mode()
2211 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL; in ice_ptp_set_timestamp_mode()
2218 ice_ptp_restore_timestamp_mode(pf); in ice_ptp_set_timestamp_mode()
2225 * @pf: Board private structure
2230 int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_set_ts_config() argument
2235 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_set_ts_config()
2241 err = ice_ptp_set_timestamp_mode(pf, &config); in ice_ptp_set_ts_config()
2246 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
2275 * PHC value, rather than accessing the PF. This also allows us to in ice_ptp_get_rx_hwts()
2288 * @pf: pointer to the PF structure
2296 ice_ptp_disable_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_disable_sma_pins_e810t() argument
2298 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_disable_sma_pins_e810t()
2311 * @pf: pointer to the PF structure
2319 ice_ptp_setup_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_sma_pins_e810t() argument
2321 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_setup_sma_pins_e810t()
2328 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
2333 err = ice_get_sma_config_e810t(&pf->hw, info->pin_config); in ice_ptp_setup_sma_pins_e810t()
2335 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
2340 * @pf: pointer to the PF instance
2344 ice_ptp_setup_pins_e810(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_pins_e810() argument
2346 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) { in ice_ptp_setup_pins_e810()
2353 ice_ptp_setup_sma_pins_e810t(pf, info); in ice_ptp_setup_pins_e810()
2354 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_setup_pins_e810()
2365 * @pf: pointer to the PF instance
2369 ice_ptp_setup_pins_e823(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_pins_e823() argument
2378 * @pf: Board private structure
2387 ice_ptp_set_funcs_e82x(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e82x() argument
2398 * @pf: Board private structure
2407 ice_ptp_set_funcs_e810(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e810() argument
2410 ice_ptp_setup_pins_e810(pf, info); in ice_ptp_set_funcs_e810()
2415 * @pf: Board private structure
2424 ice_ptp_set_funcs_e823(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e823() argument
2426 ice_ptp_set_funcs_e82x(pf, info); in ice_ptp_set_funcs_e823()
2429 ice_ptp_setup_pins_e823(pf, info); in ice_ptp_set_funcs_e823()
2434 * @pf: Board private structure
2436 static void ice_ptp_set_caps(struct ice_pf *pf) in ice_ptp_set_caps() argument
2438 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
2439 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_set_caps()
2450 if (ice_is_e810(&pf->hw)) in ice_ptp_set_caps()
2451 ice_ptp_set_funcs_e810(pf, info); in ice_ptp_set_caps()
2452 else if (ice_is_e823(&pf->hw)) in ice_ptp_set_caps()
2453 ice_ptp_set_funcs_e823(pf, info); in ice_ptp_set_caps()
2455 ice_ptp_set_funcs_e82x(pf, info); in ice_ptp_set_caps()
2460 * @pf: Board private structure
2467 static long ice_ptp_create_clock(struct ice_pf *pf) in ice_ptp_create_clock() argument
2473 if (pf->ptp.clock) in ice_ptp_create_clock()
2476 ice_ptp_set_caps(pf); in ice_ptp_create_clock()
2478 info = &pf->ptp.info; in ice_ptp_create_clock()
2479 dev = ice_pf_to_dev(pf); in ice_ptp_create_clock()
2482 pf->ptp.clock = ptp_clock_register(info, dev); in ice_ptp_create_clock()
2483 if (IS_ERR(pf->ptp.clock)) { in ice_ptp_create_clock()
2484 dev_err(ice_pf_to_dev(pf), "Failed to register PTP clock device"); in ice_ptp_create_clock()
2485 return PTR_ERR(pf->ptp.clock); in ice_ptp_create_clock()
2541 * @pf: Board private structure
2546 enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf) in ice_ptp_process_ts() argument
2548 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_process_ts()
2554 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2557 return ice_ptp_tx_tstamp_owner(pf); in ice_ptp_process_ts()
2560 pf->ptp.tx_interrupt_mode); in ice_ptp_process_ts()
2567 * @pf: Board private structure
2578 static void ice_ptp_maybe_trigger_tx_interrupt(struct ice_pf *pf) in ice_ptp_maybe_trigger_tx_interrupt() argument
2580 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_maybe_trigger_tx_interrupt()
2581 struct ice_hw *hw = &pf->hw; in ice_ptp_maybe_trigger_tx_interrupt()
2588 if (!ice_pf_src_tmr_owned(pf)) in ice_ptp_maybe_trigger_tx_interrupt()
2595 err = ice_get_phy_tx_tstamp_ready(&pf->hw, i, &tstamp_ready); in ice_ptp_maybe_trigger_tx_interrupt()
2616 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work() local
2619 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_periodic_work()
2622 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_periodic_work()
2624 ice_ptp_maybe_trigger_tx_interrupt(pf); in ice_ptp_periodic_work()
2633 * @pf: Board private structure
2635 void ice_ptp_reset(struct ice_pf *pf) in ice_ptp_reset() argument
2637 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_reset()
2638 struct ice_hw *hw = &pf->hw; in ice_ptp_reset()
2643 if (test_bit(ICE_PFR_REQ, pf->state) || in ice_ptp_reset()
2644 !ice_pf_src_tmr_owned(pf)) in ice_ptp_reset()
2658 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_reset()
2674 err = ice_ptp_write_init(pf, &ts); in ice_ptp_reset()
2685 err = ice_ptp_tx_ena_intr(pf, true, itr); in ice_ptp_reset()
2692 if (ice_is_e810(&pf->hw)) { in ice_ptp_reset()
2693 err = ice_ptp_init_tx_e810(pf, &ptp->port.tx); in ice_ptp_reset()
2697 err = ice_ptp_init_tx_e82x(pf, &ptp->port.tx, in ice_ptp_reset()
2703 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_reset()
2706 if (!test_bit(ICE_PFR_REQ, pf->state) && in ice_ptp_reset()
2707 ice_pf_src_tmr_owned(pf)) in ice_ptp_reset()
2708 ice_ptp_restart_all_phy(pf); in ice_ptp_reset()
2713 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_reset()
2717 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_reset()
2721 * ice_ptp_aux_dev_to_aux_pf - Get auxiliary PF handle for the auxiliary device
2722 * @aux_dev: auxiliary device to get the auxiliary PF for
2737 * ice_ptp_aux_dev_to_owner_pf - Get PF handle for the auxiliary device
2738 * @aux_dev: auxiliary device to get the PF for
2759 * @aux_dev: PF's auxiliary device
2782 * @aux_dev: PF's auxiliary device
2796 * @aux_dev: PF's auxiliary device
2805 * @aux_dev: PF's auxiliary device
2817 * @aux_dev: PF's auxiliary device
2827 * @pf: Board private structure
2831 ice_ptp_auxbus_create_id_table(struct ice_pf *pf, const char *name) in ice_ptp_auxbus_create_id_table() argument
2836 ids = devm_kcalloc(ice_pf_to_dev(pf), 2, in ice_ptp_auxbus_create_id_table()
2848 * @pf: Board private structure
2850 static int ice_ptp_register_auxbus_driver(struct ice_pf *pf) in ice_ptp_register_auxbus_driver() argument
2858 ptp = &pf->ptp; in ice_ptp_register_auxbus_driver()
2859 dev = ice_pf_to_dev(pf); in ice_ptp_register_auxbus_driver()
2864 pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), in ice_ptp_register_auxbus_driver()
2865 ice_get_ptp_src_clock_index(&pf->hw)); in ice_ptp_register_auxbus_driver()
2875 aux_driver->id_table = ice_ptp_auxbus_create_id_table(pf, name); in ice_ptp_register_auxbus_driver()
2891 * @pf: Board private structure
2893 static void ice_ptp_unregister_auxbus_driver(struct ice_pf *pf) in ice_ptp_unregister_auxbus_driver() argument
2895 struct auxiliary_driver *aux_driver = &pf->ptp.ports_owner.aux_driver; in ice_ptp_unregister_auxbus_driver()
2898 devm_kfree(ice_pf_to_dev(pf), aux_driver->id_table); in ice_ptp_unregister_auxbus_driver()
2900 mutex_destroy(&pf->ptp.ports_owner.lock); in ice_ptp_unregister_auxbus_driver()
2905 * @pf: Board private structure
2907 * Returns: the PTP clock index associated with this PF, or -1 if no PTP clock
2910 int ice_ptp_clock_index(struct ice_pf *pf) in ice_ptp_clock_index() argument
2916 aux_dev = &pf->ptp.port.aux_dev; in ice_ptp_clock_index()
2927 * @pf: Board private structure
2929 void ice_ptp_prepare_for_reset(struct ice_pf *pf) in ice_ptp_prepare_for_reset() argument
2931 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset()
2934 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_prepare_for_reset()
2937 ice_ptp_disable_timestamp_mode(pf); in ice_ptp_prepare_for_reset()
2941 if (test_bit(ICE_PFR_REQ, pf->state)) in ice_ptp_prepare_for_reset()
2944 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2947 ice_ptp_disable_all_clkout(pf); in ice_ptp_prepare_for_reset()
2949 src_tmr = ice_get_ptp_src_clock_index(&pf->hw); in ice_ptp_prepare_for_reset()
2952 wr32(&pf->hw, GLTSYN_ENA(src_tmr), (u32)~GLTSYN_ENA_TSYN_ENA_M); in ice_ptp_prepare_for_reset()
2960 * @pf: Board private structure
2966 static int ice_ptp_init_owner(struct ice_pf *pf) in ice_ptp_init_owner() argument
2968 struct ice_hw *hw = &pf->hw; in ice_ptp_init_owner()
2974 dev_err(ice_pf_to_dev(pf), "Failed to initialize PHC, err %d\n", in ice_ptp_init_owner()
2986 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_init_owner()
2994 err = ice_ptp_write_init(pf, &ts); in ice_ptp_init_owner()
3005 err = ice_ptp_tx_ena_intr(pf, true, itr); in ice_ptp_init_owner()
3011 err = ice_ptp_create_clock(pf); in ice_ptp_init_owner()
3015 err = ice_ptp_register_auxbus_driver(pf); in ice_ptp_init_owner()
3017 dev_err(ice_pf_to_dev(pf), "Failed to register PTP auxbus driver"); in ice_ptp_init_owner()
3023 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_init_owner()
3025 pf->ptp.clock = NULL; in ice_ptp_init_owner()
3032 * @pf: Board private structure
3033 * @ptp: PF PTP structure
3035 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
3046 dev_name(ice_pf_to_dev(pf))); in ice_ptp_init_work()
3060 * @pf: Board private structure
3063 static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) in ice_ptp_init_port() argument
3065 struct ice_hw *hw = &pf->hw; in ice_ptp_init_port()
3071 return ice_ptp_init_tx_e810(pf, &ptp_port->tx); in ice_ptp_init_port()
3076 return ice_ptp_init_tx_e82x(pf, &ptp_port->tx, in ice_ptp_init_port()
3094 * @pf: Board private structure
3096 static int ice_ptp_create_auxbus_device(struct ice_pf *pf) in ice_ptp_create_auxbus_device() argument
3105 ptp = &pf->ptp; in ice_ptp_create_auxbus_device()
3107 dev = ice_pf_to_dev(pf); in ice_ptp_create_auxbus_device()
3112 pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), in ice_ptp_create_auxbus_device()
3113 ice_get_ptp_src_clock_index(&pf->hw)); in ice_ptp_create_auxbus_device()
3141 * @pf: Board private structure
3143 static void ice_ptp_remove_auxbus_device(struct ice_pf *pf) in ice_ptp_remove_auxbus_device() argument
3145 struct auxiliary_device *aux_dev = &pf->ptp.port.aux_dev; in ice_ptp_remove_auxbus_device()
3155 * @pf: Board private structure
3158 * types, each PF processes the interrupt and manages its own timestamps. For
3162 static void ice_ptp_init_tx_interrupt_mode(struct ice_pf *pf) in ice_ptp_init_tx_interrupt_mode() argument
3164 switch (pf->hw.phy_model) { in ice_ptp_init_tx_interrupt_mode()
3169 if (ice_pf_src_tmr_owned(pf)) in ice_ptp_init_tx_interrupt_mode()
3170 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_ALL; in ice_ptp_init_tx_interrupt_mode()
3172 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_NONE; in ice_ptp_init_tx_interrupt_mode()
3176 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_SELF; in ice_ptp_init_tx_interrupt_mode()
3182 * @pf: Board private structure
3192 void ice_ptp_init(struct ice_pf *pf) in ice_ptp_init() argument
3194 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init()
3195 struct ice_hw *hw = &pf->hw; in ice_ptp_init()
3200 ice_ptp_init_tx_interrupt_mode(pf); in ice_ptp_init()
3205 if (ice_pf_src_tmr_owned(pf)) { in ice_ptp_init()
3206 err = ice_ptp_init_owner(pf); in ice_ptp_init()
3212 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
3217 ice_ptp_reset_phy_timestamping(pf); in ice_ptp_init()
3220 ice_ptp_cfg_tx_interrupt(pf); in ice_ptp_init()
3222 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
3223 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
3227 err = ice_ptp_create_auxbus_device(pf); in ice_ptp_init()
3231 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
3236 if (pf->ptp.clock) { in ice_ptp_init()
3238 pf->ptp.clock = NULL; in ice_ptp_init()
3240 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
3241 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
3246 * @pf: Board private structure
3251 void ice_ptp_release(struct ice_pf *pf) in ice_ptp_release() argument
3253 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_release()
3257 ice_ptp_disable_timestamp_mode(pf); in ice_ptp_release()
3259 ice_ptp_remove_auxbus_device(pf); in ice_ptp_release()
3261 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
3263 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_release()
3265 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
3267 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
3268 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
3269 if (pf->ptp.kworker) { in ice_ptp_release()
3270 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
3271 pf->ptp.kworker = NULL; in ice_ptp_release()
3274 if (!pf->ptp.clock) in ice_ptp_release()
3278 ice_ptp_disable_all_clkout(pf); in ice_ptp_release()
3280 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
3281 pf->ptp.clock = NULL; in ice_ptp_release()
3283 ice_ptp_unregister_auxbus_driver(pf); in ice_ptp_release()
3285 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()