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: The PF pointer to search in
263 static void ice_set_tx_tstamp(struct ice_pf *pf, bool on) in ice_set_tx_tstamp() argument
269 vsi = ice_get_main_vsi(pf); in ice_set_tx_tstamp()
281 val = rd32(&pf->hw, PFINT_OICR_ENA); in ice_set_tx_tstamp()
286 wr32(&pf->hw, PFINT_OICR_ENA, val); in ice_set_tx_tstamp()
288 pf->ptp.tstamp_config.tx_type = on ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; in ice_set_tx_tstamp()
293 * @pf: The PF pointer to search in
296 static void ice_set_rx_tstamp(struct ice_pf *pf, bool on) in ice_set_rx_tstamp() argument
301 vsi = ice_get_main_vsi(pf); in ice_set_rx_tstamp()
312 pf->ptp.tstamp_config.rx_filter = on ? HWTSTAMP_FILTER_ALL : in ice_set_rx_tstamp()
318 * @pf: Board private structure
324 void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena) in ice_ptp_cfg_timestamp() argument
326 ice_set_tx_tstamp(pf, ena); in ice_ptp_cfg_timestamp()
327 ice_set_rx_tstamp(pf, ena); in ice_ptp_cfg_timestamp()
332 * @pf: the PF pointer
335 * this is the PF controlling the clock, just use the local access to the
344 int ice_get_ptp_clock_index(struct ice_pf *pf) in ice_get_ptp_clock_index() argument
346 struct device *dev = ice_pf_to_dev(pf); in ice_get_ptp_clock_index()
348 struct ice_hw *hw = &pf->hw; in ice_get_ptp_clock_index()
353 /* Use the ptp_clock structure if we're the main PF */ in ice_get_ptp_clock_index()
354 if (pf->ptp.clock) in ice_get_ptp_clock_index()
355 return ptp_clock_index(pf->ptp.clock); in ice_get_ptp_clock_index()
382 * @pf: the PF pointer
387 * If the PF is unable to store the clock index, it will log an error, but
390 static void ice_set_ptp_clock_index(struct ice_pf *pf) in ice_set_ptp_clock_index() argument
392 struct device *dev = ice_pf_to_dev(pf); in ice_set_ptp_clock_index()
394 struct ice_hw *hw = &pf->hw; in ice_set_ptp_clock_index()
399 if (!pf->ptp.clock) in ice_set_ptp_clock_index()
408 value = (u32)ptp_clock_index(pf->ptp.clock); in ice_set_ptp_clock_index()
424 * @pf: the PF pointer
430 static void ice_clear_ptp_clock_index(struct ice_pf *pf) in ice_clear_ptp_clock_index() argument
432 struct device *dev = ice_pf_to_dev(pf); in ice_clear_ptp_clock_index()
434 struct ice_hw *hw = &pf->hw; in ice_clear_ptp_clock_index()
457 * @pf: Board private structure
462 ice_ptp_read_src_clk_reg(struct ice_pf *pf, struct ptp_system_timestamp *sts) in ice_ptp_read_src_clk_reg() argument
464 struct ice_hw *hw = &pf->hw; in ice_ptp_read_src_clk_reg()
562 * @pf: Board private structure
586 static u64 ice_ptp_extend_40b_ts(struct ice_pf *pf, u64 in_tstamp) in ice_ptp_extend_40b_ts() argument
592 discard_time = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_extend_40b_ts()
594 pf->ptp.tx_hwtstamp_discarded++; in ice_ptp_extend_40b_ts()
598 return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, in ice_ptp_extend_40b_ts()
643 struct ice_pf *pf; in ice_ptp_tx_tstamp() local
650 pf = ptp_port_to_pf(ptp_port); in ice_ptp_tx_tstamp()
661 err = ice_read_phy_tstamp(&pf->hw, tx->quad, phy_idx, in ice_ptp_tx_tstamp()
690 tstamp = ice_ptp_extend_40b_ts(pf, raw_tstamp); in ice_ptp_tx_tstamp()
741 * @pf: Board private structure
745 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
756 pf->ptp.tx_hwtstamp_flushed++; in ice_ptp_flush_tx_tracker()
762 if (!pf->hw.reset_ongoing) in ice_ptp_flush_tx_tracker()
763 ice_clear_phy_tstamp(&pf->hw, tx->quad, phy_idx); in ice_ptp_flush_tx_tracker()
769 * @pf: Board private structure
775 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
779 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
792 * @pf: Board private structure
802 ice_ptp_init_tx_e822(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) in ice_ptp_init_tx_e822() argument
813 * @pf: Board private structure
816 * Initialize the Tx timestamp tracker for this PF. For E810 devices, each
820 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
822 tx->quad = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
831 * @pf: pointer to the PF struct
840 static void ice_ptp_tx_tstamp_cleanup(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_tx_tstamp_cleanup() argument
842 struct ice_hw *hw = &pf->hw; in ice_ptp_tx_tstamp_cleanup()
867 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_tx_tstamp_cleanup()
876 * @pf: Board specific private structure
878 * This function updates the system time values which are cached in the PF
884 * Note that the cached copy in the PF PTP structure is always updated, even
889 * * -EAGAIN - PF was busy, need to reschedule the update
891 static int ice_ptp_update_cached_phctime(struct ice_pf *pf) in ice_ptp_update_cached_phctime() argument
893 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_update_cached_phctime()
898 update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_update_cached_phctime()
899 if (pf->ptp.cached_phc_time && in ice_ptp_update_cached_phctime()
901 unsigned long time_taken = jiffies - pf->ptp.cached_phc_jiffies; in ice_ptp_update_cached_phctime()
905 pf->ptp.late_cached_phc_updates++; in ice_ptp_update_cached_phctime()
909 systime = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_update_cached_phctime()
911 /* Update the cached PHC time stored in the PF structure */ in ice_ptp_update_cached_phctime()
912 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
913 WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); in ice_ptp_update_cached_phctime()
915 if (test_and_set_bit(ICE_CFG_BUSY, pf->state)) in ice_ptp_update_cached_phctime()
918 ice_for_each_vsi(pf, i) { in ice_ptp_update_cached_phctime()
919 struct ice_vsi *vsi = pf->vsi[i]; in ice_ptp_update_cached_phctime()
934 clear_bit(ICE_CFG_BUSY, pf->state); in ice_ptp_update_cached_phctime()
941 * @pf: Board specific private structure
945 * and updates the cached PHC time for both the PF and Rx rings. If updating
959 static void ice_ptp_reset_cached_phctime(struct ice_pf *pf) in ice_ptp_reset_cached_phctime() argument
961 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_reset_cached_phctime()
967 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_reset_cached_phctime()
977 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, in ice_ptp_reset_cached_phctime()
982 ice_ptp_flush_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
987 * @pf: Board private structure
997 ice_ptp_read_time(struct ice_pf *pf, struct timespec64 *ts, in ice_ptp_read_time() argument
1000 u64 time_ns = ice_ptp_read_src_clk_reg(pf, sts); in ice_ptp_read_time()
1007 * @pf: Board private structure
1012 static int ice_ptp_write_init(struct ice_pf *pf, struct timespec64 *ts) in ice_ptp_write_init() argument
1015 struct ice_hw *hw = &pf->hw; in ice_ptp_write_init()
1022 * @pf: Board private structure
1028 static int ice_ptp_write_adj(struct ice_pf *pf, s32 adj) in ice_ptp_write_adj() argument
1030 struct ice_hw *hw = &pf->hw; in ice_ptp_write_adj()
1037 * @pf: Board private structure
1044 static u64 ice_base_incval(struct ice_pf *pf) in ice_base_incval() argument
1046 struct ice_hw *hw = &pf->hw; in ice_base_incval()
1056 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
1064 * @pf: The PF private data structure
1067 static void ice_ptp_reset_ts_memory_quad(struct ice_pf *pf, int quad) in ice_ptp_reset_ts_memory_quad() argument
1069 struct ice_hw *hw = &pf->hw; in ice_ptp_reset_ts_memory_quad()
1083 struct ice_pf *pf; in ice_ptp_check_tx_fifo() local
1088 pf = ptp_port_to_pf(port); in ice_ptp_check_tx_fifo()
1089 hw = &pf->hw; in ice_ptp_check_tx_fifo()
1103 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1120 dev_dbg(ice_pf_to_dev(pf), "Try %d, port %d FIFO not empty\n", in ice_ptp_check_tx_fifo()
1124 dev_dbg(ice_pf_to_dev(pf), in ice_ptp_check_tx_fifo()
1127 ice_ptp_reset_ts_memory_quad(pf, quad); in ice_ptp_check_tx_fifo()
1145 struct ice_pf *pf = ptp_port_to_pf(port); in ice_ptp_check_tx_offset_valid() local
1146 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_check_tx_offset_valid()
1147 struct ice_hw *hw = &pf->hw; in ice_ptp_check_tx_offset_valid()
1179 struct ice_pf *pf = ptp_port_to_pf(port); in ice_ptp_check_rx_offset_valid() local
1180 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_check_rx_offset_valid()
1181 struct ice_hw *hw = &pf->hw; in ice_ptp_check_rx_offset_valid()
1236 struct ice_pf *pf; in ice_ptp_wait_for_offset_valid() local
1240 pf = ptp_port_to_pf(port); in ice_ptp_wait_for_offset_valid()
1241 hw = &pf->hw; in ice_ptp_wait_for_offset_valid()
1242 dev = ice_pf_to_dev(pf); in ice_ptp_wait_for_offset_valid()
1244 if (ice_is_reset_in_progress(pf->state)) in ice_ptp_wait_for_offset_valid()
1249 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offset_valid()
1271 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_stop() local
1273 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_stop()
1285 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
1304 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_restart() local
1306 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_restart()
1331 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0); in ice_ptp_port_phy_restart()
1335 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1345 * @pf: Board private structure
1349 int ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) in ice_ptp_link_change() argument
1353 if (!test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_ptp_link_change()
1359 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1366 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_link_change()
1375 * @pf: The PF private data structure
1377 static void ice_ptp_reset_ts_memory(struct ice_pf *pf) in ice_ptp_reset_ts_memory() argument
1381 quad = pf->hw.port_info->lport / ICE_PORTS_PER_QUAD; in ice_ptp_reset_ts_memory()
1382 ice_ptp_reset_ts_memory_quad(pf, quad); in ice_ptp_reset_ts_memory()
1387 * @pf: PF private structure
1393 static int ice_ptp_tx_ena_intr(struct ice_pf *pf, bool ena, u32 threshold) in ice_ptp_tx_ena_intr() argument
1395 struct ice_hw *hw = &pf->hw; in ice_ptp_tx_ena_intr()
1400 ice_ptp_reset_ts_memory(pf); in ice_ptp_tx_ena_intr()
1424 dev_err(ice_pf_to_dev(pf), "PTP failed in intr ena, err %d\n", in ice_ptp_tx_ena_intr()
1431 * @pf: Board private structure
1433 static void ice_ptp_reset_phy_timestamping(struct ice_pf *pf) in ice_ptp_reset_phy_timestamping() argument
1435 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1448 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjfine() local
1449 struct ice_hw *hw = &pf->hw; in ice_ptp_adjfine()
1454 incval = ice_base_incval(pf); in ice_ptp_adjfine()
1470 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1487 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_extts_work() local
1489 struct ice_hw *hw = &pf->hw; in ice_ptp_extts_work()
1501 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_work()
1509 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_work()
1510 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_work()
1517 * @pf: Board private structure
1524 ice_ptp_cfg_extts(struct ice_pf *pf, bool ena, unsigned int chan, u32 gpio_pin, in ice_ptp_cfg_extts() argument
1528 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_extts()
1531 if (chan > (unsigned int)pf->ptp.info.n_ext_ts) in ice_ptp_cfg_extts()
1559 pf->ptp.ext_ts_chan |= (1 << chan); in ice_ptp_cfg_extts()
1564 pf->ptp.ext_ts_chan &= ~(1 << chan); in ice_ptp_cfg_extts()
1565 if (!pf->ptp.ext_ts_chan) in ice_ptp_cfg_extts()
1578 * @pf: Board private structure
1586 static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan, in ice_ptp_cfg_clkout() argument
1590 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_clkout()
1608 gpio_pin = pf->ptp.perout_channels[chan].gpio_pin; in ice_ptp_cfg_clkout()
1613 memset(&pf->ptp.perout_channels[chan], 0, in ice_ptp_cfg_clkout()
1625 dev_err(ice_pf_to_dev(pf), "CLK Period must be an even value\n"); in ice_ptp_cfg_clkout()
1635 dev_err(ice_pf_to_dev(pf), "CLK Period must be > %d && < 2^33", in ice_ptp_cfg_clkout()
1643 current_time = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_cfg_clkout()
1673 memcpy(&pf->ptp.perout_channels[chan], config, in ice_ptp_cfg_clkout()
1675 pf->ptp.perout_channels[chan].start_time = phase; in ice_ptp_cfg_clkout()
1680 dev_err(ice_pf_to_dev(pf), "PTP failed to cfg per_clk\n"); in ice_ptp_cfg_clkout()
1686 * @pf: pointer to the PF structure
1692 static void ice_ptp_disable_all_clkout(struct ice_pf *pf) in ice_ptp_disable_all_clkout() argument
1696 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_clkout()
1697 if (pf->ptp.perout_channels[i].ena) in ice_ptp_disable_all_clkout()
1698 ice_ptp_cfg_clkout(pf, i, NULL, false); in ice_ptp_disable_all_clkout()
1703 * @pf: pointer to the PF structure
1709 static void ice_ptp_enable_all_clkout(struct ice_pf *pf) in ice_ptp_enable_all_clkout() argument
1713 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_clkout()
1714 if (pf->ptp.perout_channels[i].ena) in ice_ptp_enable_all_clkout()
1715 ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], in ice_ptp_enable_all_clkout()
1729 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gpio_enable_e810() local
1736 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) in ice_ptp_gpio_enable_e810()
1749 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1766 err = ice_ptp_cfg_clkout(pf, chan, &clk_cfg, true); in ice_ptp_gpio_enable_e810()
1775 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1784 err = ice_ptp_cfg_extts(pf, !!on, chan, gpio_pin, in ice_ptp_gpio_enable_e810()
1808 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gettimex64() local
1809 struct ice_hw *hw = &pf->hw; in ice_ptp_gettimex64()
1812 dev_err(ice_pf_to_dev(pf), "PTP failed to get time\n"); in ice_ptp_gettimex64()
1816 ice_ptp_read_time(pf, ts, sts); in ice_ptp_gettimex64()
1833 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_settime64() local
1835 struct ice_hw *hw = &pf->hw; in ice_ptp_settime64()
1841 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1842 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_settime64()
1850 ice_ptp_disable_all_clkout(pf); in ice_ptp_settime64()
1852 err = ice_ptp_write_init(pf, &ts64); in ice_ptp_settime64()
1856 ice_ptp_reset_cached_phctime(pf); in ice_ptp_settime64()
1859 ice_ptp_enable_all_clkout(pf); in ice_ptp_settime64()
1862 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1863 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_settime64()
1866 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
1899 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjtime() local
1900 struct ice_hw *hw = &pf->hw; in ice_ptp_adjtime()
1904 dev = ice_pf_to_dev(pf); in ice_ptp_adjtime()
1921 ice_ptp_disable_all_clkout(pf); in ice_ptp_adjtime()
1923 err = ice_ptp_write_adj(pf, delta); in ice_ptp_adjtime()
1926 ice_ptp_enable_all_clkout(pf); in ice_ptp_adjtime()
1935 ice_ptp_reset_cached_phctime(pf); in ice_ptp_adjtime()
1955 struct ice_pf *pf = (struct ice_pf *)ctx; in ice_ptp_get_syncdevicetime() local
1956 struct ice_hw *hw = &pf->hw; in ice_ptp_get_syncdevicetime()
1963 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
2028 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_getcrosststamp_e822() local
2031 pf, NULL, cts); in ice_ptp_getcrosststamp_e822()
2037 * @pf: Board private structure
2042 int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_get_ts_config() argument
2046 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_get_ts_config()
2049 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
2057 * @pf: Board private structure
2061 ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) in ice_ptp_set_timestamp_mode() argument
2065 ice_set_tx_tstamp(pf, false); in ice_ptp_set_timestamp_mode()
2068 ice_set_tx_tstamp(pf, true); in ice_ptp_set_timestamp_mode()
2076 ice_set_rx_tstamp(pf, false); in ice_ptp_set_timestamp_mode()
2092 ice_set_rx_tstamp(pf, true); in ice_ptp_set_timestamp_mode()
2103 * @pf: Board private structure
2108 int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_set_ts_config() argument
2113 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_set_ts_config()
2119 err = ice_ptp_set_timestamp_mode(pf, &config); in ice_ptp_set_ts_config()
2124 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
2157 * PHC value, rather than accessing the PF. This also allows us to in ice_ptp_rx_hwtstamp()
2172 * @pf: pointer to the PF structure
2180 ice_ptp_disable_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_disable_sma_pins_e810t() argument
2182 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_disable_sma_pins_e810t()
2195 * @pf: pointer to the PF structure
2203 ice_ptp_setup_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_sma_pins_e810t() argument
2205 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_setup_sma_pins_e810t()
2212 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
2217 err = ice_get_sma_config_e810t(&pf->hw, info->pin_config); in ice_ptp_setup_sma_pins_e810t()
2219 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
2224 * @pf: pointer to the PF instance
2228 ice_ptp_setup_pins_e810(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_pins_e810() argument
2232 if (ice_is_feature_supported(pf, ICE_F_PTP_EXTTS)) in ice_ptp_setup_pins_e810()
2235 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) { in ice_ptp_setup_pins_e810()
2241 ice_ptp_setup_sma_pins_e810t(pf, info); in ice_ptp_setup_pins_e810()
2247 * @pf: Board private structure
2256 ice_ptp_set_funcs_e822(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e822() argument
2267 * @pf: Board private structure
2276 ice_ptp_set_funcs_e810(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e810() argument
2279 ice_ptp_setup_pins_e810(pf, info); in ice_ptp_set_funcs_e810()
2284 * @pf: Board private structure
2286 static void ice_ptp_set_caps(struct ice_pf *pf) in ice_ptp_set_caps() argument
2288 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
2289 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_set_caps()
2300 if (ice_is_e810(&pf->hw)) in ice_ptp_set_caps()
2301 ice_ptp_set_funcs_e810(pf, info); in ice_ptp_set_caps()
2303 ice_ptp_set_funcs_e822(pf, info); in ice_ptp_set_caps()
2308 * @pf: Board private structure
2315 static long ice_ptp_create_clock(struct ice_pf *pf) in ice_ptp_create_clock() argument
2322 if (pf->ptp.clock) in ice_ptp_create_clock()
2325 ice_ptp_set_caps(pf); in ice_ptp_create_clock()
2327 info = &pf->ptp.info; in ice_ptp_create_clock()
2328 dev = ice_pf_to_dev(pf); in ice_ptp_create_clock()
2335 pf->ptp.clock = clock; in ice_ptp_create_clock()
2381 * @pf: Board private structure
2385 bool ice_ptp_process_ts(struct ice_pf *pf) in ice_ptp_process_ts() argument
2387 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2393 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work() local
2396 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_periodic_work()
2399 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_periodic_work()
2401 ice_ptp_tx_tstamp_cleanup(pf, &pf->ptp.port.tx); in ice_ptp_periodic_work()
2410 * @pf: Board private structure
2412 void ice_ptp_reset(struct ice_pf *pf) in ice_ptp_reset() argument
2414 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_reset()
2415 struct ice_hw *hw = &pf->hw; in ice_ptp_reset()
2420 if (test_bit(ICE_PFR_REQ, pf->state)) in ice_ptp_reset()
2437 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_reset()
2453 err = ice_ptp_write_init(pf, &ts); in ice_ptp_reset()
2464 err = ice_ptp_tx_ena_intr(pf, true, itr); in ice_ptp_reset()
2471 ice_ptp_reset_phy_timestamping(pf); in ice_ptp_reset()
2475 if (ice_is_e810(&pf->hw)) { in ice_ptp_reset()
2476 err = ice_ptp_init_tx_e810(pf, &ptp->port.tx); in ice_ptp_reset()
2480 err = ice_ptp_init_tx_e822(pf, &ptp->port.tx, in ice_ptp_reset()
2486 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_reset()
2491 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_reset()
2495 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_reset()
2500 * @pf: Board private structure
2502 void ice_ptp_prepare_for_reset(struct ice_pf *pf) in ice_ptp_prepare_for_reset() argument
2504 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset()
2507 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_prepare_for_reset()
2510 ice_ptp_cfg_timestamp(pf, false); in ice_ptp_prepare_for_reset()
2515 if (test_bit(ICE_PFR_REQ, pf->state)) in ice_ptp_prepare_for_reset()
2518 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2521 ice_ptp_disable_all_clkout(pf); in ice_ptp_prepare_for_reset()
2523 src_tmr = ice_get_ptp_src_clock_index(&pf->hw); in ice_ptp_prepare_for_reset()
2526 wr32(&pf->hw, GLTSYN_ENA(src_tmr), (u32)~GLTSYN_ENA_TSYN_ENA_M); in ice_ptp_prepare_for_reset()
2534 * @pf: Board private structure
2540 static int ice_ptp_init_owner(struct ice_pf *pf) in ice_ptp_init_owner() argument
2542 struct ice_hw *hw = &pf->hw; in ice_ptp_init_owner()
2548 dev_err(ice_pf_to_dev(pf), "Failed to initialize PHC, err %d\n", in ice_ptp_init_owner()
2560 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_init_owner()
2568 err = ice_ptp_write_init(pf, &ts); in ice_ptp_init_owner()
2579 err = ice_ptp_tx_ena_intr(pf, true, itr); in ice_ptp_init_owner()
2585 err = ice_ptp_create_clock(pf); in ice_ptp_init_owner()
2590 ice_set_ptp_clock_index(pf); in ice_ptp_init_owner()
2595 pf->ptp.clock = NULL; in ice_ptp_init_owner()
2602 * @pf: Board private structure
2603 * @ptp: PF PTP structure
2605 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
2617 dev_name(ice_pf_to_dev(pf))); in ice_ptp_init_work()
2631 * @pf: Board private structure
2634 static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) in ice_ptp_init_port() argument
2638 if (ice_is_e810(&pf->hw)) in ice_ptp_init_port()
2639 return ice_ptp_init_tx_e810(pf, &ptp_port->tx); in ice_ptp_init_port()
2643 return ice_ptp_init_tx_e822(pf, &ptp_port->tx, ptp_port->port_num); in ice_ptp_init_port()
2648 * @pf: Board private structure
2658 void ice_ptp_init(struct ice_pf *pf) in ice_ptp_init() argument
2660 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init()
2661 struct ice_hw *hw = &pf->hw; in ice_ptp_init()
2668 err = ice_ptp_init_owner(pf); in ice_ptp_init()
2674 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
2679 ice_ptp_reset_phy_timestamping(pf); in ice_ptp_init()
2681 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
2682 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
2686 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
2691 if (pf->ptp.clock) { in ice_ptp_init()
2693 pf->ptp.clock = NULL; in ice_ptp_init()
2695 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
2696 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
2701 * @pf: Board private structure
2706 void ice_ptp_release(struct ice_pf *pf) in ice_ptp_release() argument
2708 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_release()
2712 ice_ptp_cfg_timestamp(pf, false); in ice_ptp_release()
2714 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
2716 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_release()
2718 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
2720 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
2721 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
2722 if (pf->ptp.kworker) { in ice_ptp_release()
2723 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
2724 pf->ptp.kworker = NULL; in ice_ptp_release()
2727 if (!pf->ptp.clock) in ice_ptp_release()
2731 ice_ptp_disable_all_clkout(pf); in ice_ptp_release()
2733 ice_clear_ptp_clock_index(pf); in ice_ptp_release()
2734 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
2735 pf->ptp.clock = NULL; in ice_ptp_release()
2737 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()