Lines Matching refs: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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
670 struct ice_pf *pf; in ice_ptp_process_tx_tstamp() local
681 pf = ptp_port_to_pf(ptp_port); in ice_ptp_process_tx_tstamp()
682 hw = &pf->hw; in ice_ptp_process_tx_tstamp()
704 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_process_tx_tstamp()
766 tstamp = ice_ptp_extend_40b_ts(pf, raw_tstamp); in ice_ptp_process_tx_tstamp()
848 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
850 struct ice_hw *hw = &pf->hw; in ice_ptp_flush_tx_tracker()
857 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()
882 pf->ptp.tx_hwtstamp_flushed++; in ice_ptp_flush_tx_tracker()
916 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
923 synchronize_irq(pf->oicr_irq.virq); in ice_ptp_release_tx_tracker()
925 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
951 ice_ptp_init_tx_e822(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) in ice_ptp_init_tx_e822() argument
970 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
972 tx->block = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
1001 static int ice_ptp_update_cached_phctime(struct ice_pf *pf) in ice_ptp_update_cached_phctime() argument
1003 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_update_cached_phctime()
1008 update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_update_cached_phctime()
1009 if (pf->ptp.cached_phc_time && in ice_ptp_update_cached_phctime()
1011 unsigned long time_taken = jiffies - pf->ptp.cached_phc_jiffies; in ice_ptp_update_cached_phctime()
1015 pf->ptp.late_cached_phc_updates++; in ice_ptp_update_cached_phctime()
1019 systime = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_update_cached_phctime()
1022 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
1023 WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); in ice_ptp_update_cached_phctime()
1025 if (test_and_set_bit(ICE_CFG_BUSY, pf->state)) in ice_ptp_update_cached_phctime()
1028 ice_for_each_vsi(pf, i) { in ice_ptp_update_cached_phctime()
1029 struct ice_vsi *vsi = pf->vsi[i]; in ice_ptp_update_cached_phctime()
1044 clear_bit(ICE_CFG_BUSY, pf->state); in ice_ptp_update_cached_phctime()
1062 static void ice_ptp_reset_cached_phctime(struct ice_pf *pf) in ice_ptp_reset_cached_phctime() argument
1064 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_reset_cached_phctime()
1070 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_reset_cached_phctime()
1080 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, in ice_ptp_reset_cached_phctime()
1089 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1104 ice_ptp_read_time(struct ice_pf *pf, struct timespec64 *ts, in ice_ptp_read_time() argument
1107 u64 time_ns = ice_ptp_read_src_clk_reg(pf, sts); in ice_ptp_read_time()
1119 static int ice_ptp_write_init(struct ice_pf *pf, struct timespec64 *ts) in ice_ptp_write_init() argument
1122 struct ice_hw *hw = &pf->hw; in ice_ptp_write_init()
1135 static int ice_ptp_write_adj(struct ice_pf *pf, s32 adj) in ice_ptp_write_adj() argument
1137 struct ice_hw *hw = &pf->hw; in ice_ptp_write_adj()
1151 static u64 ice_base_incval(struct ice_pf *pf) in ice_base_incval() argument
1153 struct ice_hw *hw = &pf->hw; in ice_base_incval()
1163 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
1177 struct ice_pf *pf; in ice_ptp_check_tx_fifo() local
1182 pf = ptp_port_to_pf(port); in ice_ptp_check_tx_fifo()
1183 hw = &pf->hw; in ice_ptp_check_tx_fifo()
1197 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1214 dev_dbg(ice_pf_to_dev(pf), "Try %d, port %d FIFO not empty\n", in ice_ptp_check_tx_fifo()
1218 dev_dbg(ice_pf_to_dev(pf), in ice_ptp_check_tx_fifo()
1247 struct ice_pf *pf; in ice_ptp_wait_for_offsets() local
1253 pf = ptp_port_to_pf(port); in ice_ptp_wait_for_offsets()
1254 hw = &pf->hw; in ice_ptp_wait_for_offsets()
1256 if (ice_is_reset_in_progress(pf->state)) { in ice_ptp_wait_for_offsets()
1258 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1270 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1284 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_stop() local
1286 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_stop()
1298 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
1317 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_restart() local
1319 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_restart()
1348 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0); in ice_ptp_port_phy_restart()
1352 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1366 void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) in ice_ptp_link_change() argument
1370 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_link_change()
1376 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1384 if (ice_is_e810(&pf->hw)) in ice_ptp_link_change()
1398 static int ice_ptp_tx_ena_intr(struct ice_pf *pf, bool ena, u32 threshold) in ice_ptp_tx_ena_intr() argument
1400 struct ice_hw *hw = &pf->hw; in ice_ptp_tx_ena_intr()
1429 dev_err(ice_pf_to_dev(pf), "PTP failed in intr ena, err %d\n", in ice_ptp_tx_ena_intr()
1438 static void ice_ptp_reset_phy_timestamping(struct ice_pf *pf) in ice_ptp_reset_phy_timestamping() argument
1440 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1453 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjfine() local
1454 struct ice_hw *hw = &pf->hw; in ice_ptp_adjfine()
1458 incval = adjust_by_scaled_ppm(ice_base_incval(pf), scaled_ppm); in ice_ptp_adjfine()
1461 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1473 void ice_ptp_extts_event(struct ice_pf *pf) in ice_ptp_extts_event() argument
1476 struct ice_hw *hw = &pf->hw; in ice_ptp_extts_event()
1488 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_event()
1496 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_event()
1497 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_event()
1511 ice_ptp_cfg_extts(struct ice_pf *pf, bool ena, unsigned int chan, u32 gpio_pin, in ice_ptp_cfg_extts() argument
1515 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_extts()
1518 if (chan > (unsigned int)pf->ptp.info.n_ext_ts) in ice_ptp_cfg_extts()
1546 pf->ptp.ext_ts_chan |= (1 << chan); in ice_ptp_cfg_extts()
1551 pf->ptp.ext_ts_chan &= ~(1 << chan); in ice_ptp_cfg_extts()
1552 if (!pf->ptp.ext_ts_chan) in ice_ptp_cfg_extts()
1573 static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan, in ice_ptp_cfg_clkout() argument
1577 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_clkout()
1595 gpio_pin = pf->ptp.perout_channels[chan].gpio_pin; in ice_ptp_cfg_clkout()
1600 memset(&pf->ptp.perout_channels[chan], 0, in ice_ptp_cfg_clkout()
1612 dev_err(ice_pf_to_dev(pf), "CLK Period must be an even value\n"); in ice_ptp_cfg_clkout()
1622 dev_err(ice_pf_to_dev(pf), "CLK Period must be > %d && < 2^33", in ice_ptp_cfg_clkout()
1630 current_time = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_cfg_clkout()
1660 memcpy(&pf->ptp.perout_channels[chan], config, in ice_ptp_cfg_clkout()
1662 pf->ptp.perout_channels[chan].start_time = phase; in ice_ptp_cfg_clkout()
1667 dev_err(ice_pf_to_dev(pf), "PTP failed to cfg per_clk\n"); in ice_ptp_cfg_clkout()
1679 static void ice_ptp_disable_all_clkout(struct ice_pf *pf) in ice_ptp_disable_all_clkout() argument
1683 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_clkout()
1684 if (pf->ptp.perout_channels[i].ena) in ice_ptp_disable_all_clkout()
1685 ice_ptp_cfg_clkout(pf, i, NULL, false); in ice_ptp_disable_all_clkout()
1696 static void ice_ptp_enable_all_clkout(struct ice_pf *pf) in ice_ptp_enable_all_clkout() argument
1700 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_clkout()
1701 if (pf->ptp.perout_channels[i].ena) in ice_ptp_enable_all_clkout()
1702 ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], in ice_ptp_enable_all_clkout()
1716 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gpio_enable_e810() local
1723 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) in ice_ptp_gpio_enable_e810()
1736 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1753 err = ice_ptp_cfg_clkout(pf, chan, &clk_cfg, true); in ice_ptp_gpio_enable_e810()
1762 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1771 err = ice_ptp_cfg_extts(pf, !!on, chan, gpio_pin, in ice_ptp_gpio_enable_e810()
1790 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gpio_enable_e823() local
1800 err = ice_ptp_cfg_clkout(pf, PPS_CLK_GEN_CHAN, &clk_cfg, true); in ice_ptp_gpio_enable_e823()
1803 err = ice_ptp_cfg_extts(pf, !!on, rq->extts.index, in ice_ptp_gpio_enable_e823()
1827 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gettimex64() local
1828 struct ice_hw *hw = &pf->hw; in ice_ptp_gettimex64()
1831 dev_err(ice_pf_to_dev(pf), "PTP failed to get time\n"); in ice_ptp_gettimex64()
1835 ice_ptp_read_time(pf, ts, sts); in ice_ptp_gettimex64()
1852 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_settime64() local
1854 struct ice_hw *hw = &pf->hw; in ice_ptp_settime64()
1860 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1861 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_settime64()
1869 ice_ptp_disable_all_clkout(pf); in ice_ptp_settime64()
1871 err = ice_ptp_write_init(pf, &ts64); in ice_ptp_settime64()
1875 ice_ptp_reset_cached_phctime(pf); in ice_ptp_settime64()
1878 ice_ptp_enable_all_clkout(pf); in ice_ptp_settime64()
1881 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1882 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_settime64()
1885 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
1918 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjtime() local
1919 struct ice_hw *hw = &pf->hw; in ice_ptp_adjtime()
1923 dev = ice_pf_to_dev(pf); in ice_ptp_adjtime()
1940 ice_ptp_disable_all_clkout(pf); in ice_ptp_adjtime()
1942 err = ice_ptp_write_adj(pf, delta); in ice_ptp_adjtime()
1945 ice_ptp_enable_all_clkout(pf); in ice_ptp_adjtime()
1954 ice_ptp_reset_cached_phctime(pf); in ice_ptp_adjtime()
1974 struct ice_pf *pf = (struct ice_pf *)ctx; in ice_ptp_get_syncdevicetime() local
1975 struct ice_hw *hw = &pf->hw; in ice_ptp_get_syncdevicetime()
1982 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
2047 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_getcrosststamp_e822() local
2050 pf, NULL, cts); in ice_ptp_getcrosststamp_e822()
2061 int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_get_ts_config() argument
2065 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_get_ts_config()
2068 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
2080 ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) in ice_ptp_set_timestamp_mode() argument
2084 ice_set_tx_tstamp(pf, false); in ice_ptp_set_timestamp_mode()
2087 ice_set_tx_tstamp(pf, true); in ice_ptp_set_timestamp_mode()
2095 ice_set_rx_tstamp(pf, false); in ice_ptp_set_timestamp_mode()
2111 ice_set_rx_tstamp(pf, true); in ice_ptp_set_timestamp_mode()
2127 int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_set_ts_config() argument
2132 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_set_ts_config()
2138 err = ice_ptp_set_timestamp_mode(pf, &config); in ice_ptp_set_ts_config()
2143 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
2199 ice_ptp_disable_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_disable_sma_pins_e810t() argument
2201 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_disable_sma_pins_e810t()
2222 ice_ptp_setup_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_sma_pins_e810t() argument
2224 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_setup_sma_pins_e810t()
2231 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
2236 err = ice_get_sma_config_e810t(&pf->hw, info->pin_config); in ice_ptp_setup_sma_pins_e810t()
2238 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
2247 ice_ptp_setup_pins_e810(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_pins_e810() argument
2249 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) { in ice_ptp_setup_pins_e810()
2256 ice_ptp_setup_sma_pins_e810t(pf, info); in ice_ptp_setup_pins_e810()
2257 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_setup_pins_e810()
2272 ice_ptp_setup_pins_e823(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_pins_e823() argument
2290 ice_ptp_set_funcs_e822(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e822() argument
2310 ice_ptp_set_funcs_e810(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e810() argument
2313 ice_ptp_setup_pins_e810(pf, info); in ice_ptp_set_funcs_e810()
2327 ice_ptp_set_funcs_e823(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e823() argument
2330 ice_ptp_setup_pins_e823(pf, info); in ice_ptp_set_funcs_e823()
2337 static void ice_ptp_set_caps(struct ice_pf *pf) in ice_ptp_set_caps() argument
2339 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
2340 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_set_caps()
2351 if (ice_is_e810(&pf->hw)) in ice_ptp_set_caps()
2352 ice_ptp_set_funcs_e810(pf, info); in ice_ptp_set_caps()
2353 else if (ice_is_e823(&pf->hw)) in ice_ptp_set_caps()
2354 ice_ptp_set_funcs_e823(pf, info); in ice_ptp_set_caps()
2356 ice_ptp_set_funcs_e822(pf, info); in ice_ptp_set_caps()
2368 static long ice_ptp_create_clock(struct ice_pf *pf) in ice_ptp_create_clock() argument
2375 if (pf->ptp.clock) in ice_ptp_create_clock()
2378 ice_ptp_set_caps(pf); in ice_ptp_create_clock()
2380 info = &pf->ptp.info; in ice_ptp_create_clock()
2381 dev = ice_pf_to_dev(pf); in ice_ptp_create_clock()
2388 pf->ptp.clock = clock; in ice_ptp_create_clock()
2443 enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf) in ice_ptp_process_ts() argument
2445 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2451 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work() local
2454 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_periodic_work()
2457 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_periodic_work()
2468 void ice_ptp_reset(struct ice_pf *pf) in ice_ptp_reset() argument
2470 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_reset()
2471 struct ice_hw *hw = &pf->hw; in ice_ptp_reset()
2476 if (test_bit(ICE_PFR_REQ, pf->state)) in ice_ptp_reset()
2493 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_reset()
2509 err = ice_ptp_write_init(pf, &ts); in ice_ptp_reset()
2520 err = ice_ptp_tx_ena_intr(pf, true, itr); in ice_ptp_reset()
2527 ice_ptp_reset_phy_timestamping(pf); in ice_ptp_reset()
2531 if (ice_is_e810(&pf->hw)) { in ice_ptp_reset()
2532 err = ice_ptp_init_tx_e810(pf, &ptp->port.tx); in ice_ptp_reset()
2536 err = ice_ptp_init_tx_e822(pf, &ptp->port.tx, in ice_ptp_reset()
2542 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_reset()
2547 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_reset()
2551 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_reset()
2558 void ice_ptp_prepare_for_reset(struct ice_pf *pf) in ice_ptp_prepare_for_reset() argument
2560 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset()
2563 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_prepare_for_reset()
2566 ice_ptp_cfg_timestamp(pf, false); in ice_ptp_prepare_for_reset()
2570 if (test_bit(ICE_PFR_REQ, pf->state)) in ice_ptp_prepare_for_reset()
2573 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2576 ice_ptp_disable_all_clkout(pf); in ice_ptp_prepare_for_reset()
2578 src_tmr = ice_get_ptp_src_clock_index(&pf->hw); in ice_ptp_prepare_for_reset()
2581 wr32(&pf->hw, GLTSYN_ENA(src_tmr), (u32)~GLTSYN_ENA_TSYN_ENA_M); in ice_ptp_prepare_for_reset()
2595 static int ice_ptp_init_owner(struct ice_pf *pf) in ice_ptp_init_owner() argument
2597 struct ice_hw *hw = &pf->hw; in ice_ptp_init_owner()
2603 dev_err(ice_pf_to_dev(pf), "Failed to initialize PHC, err %d\n", in ice_ptp_init_owner()
2615 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_init_owner()
2623 err = ice_ptp_write_init(pf, &ts); in ice_ptp_init_owner()
2634 err = ice_ptp_tx_ena_intr(pf, true, itr); in ice_ptp_init_owner()
2640 err = ice_ptp_create_clock(pf); in ice_ptp_init_owner()
2645 ice_set_ptp_clock_index(pf); in ice_ptp_init_owner()
2650 pf->ptp.clock = NULL; in ice_ptp_init_owner()
2660 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
2671 dev_name(ice_pf_to_dev(pf))); in ice_ptp_init_work()
2688 static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) in ice_ptp_init_port() argument
2692 if (ice_is_e810(&pf->hw)) in ice_ptp_init_port()
2693 return ice_ptp_init_tx_e810(pf, &ptp_port->tx); in ice_ptp_init_port()
2697 return ice_ptp_init_tx_e822(pf, &ptp_port->tx, ptp_port->port_num); in ice_ptp_init_port()
2712 void ice_ptp_init(struct ice_pf *pf) in ice_ptp_init() argument
2714 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init()
2715 struct ice_hw *hw = &pf->hw; in ice_ptp_init()
2722 err = ice_ptp_init_owner(pf); in ice_ptp_init()
2728 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
2733 ice_ptp_reset_phy_timestamping(pf); in ice_ptp_init()
2735 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
2736 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
2740 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
2745 if (pf->ptp.clock) { in ice_ptp_init()
2747 pf->ptp.clock = NULL; in ice_ptp_init()
2749 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
2750 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
2760 void ice_ptp_release(struct ice_pf *pf) in ice_ptp_release() argument
2762 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_release()
2766 ice_ptp_cfg_timestamp(pf, false); in ice_ptp_release()
2768 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
2770 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_release()
2772 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
2774 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
2775 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
2776 if (pf->ptp.kworker) { in ice_ptp_release()
2777 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
2778 pf->ptp.kworker = NULL; in ice_ptp_release()
2781 if (!pf->ptp.clock) in ice_ptp_release()
2785 ice_ptp_disable_all_clkout(pf); in ice_ptp_release()
2787 ice_clear_ptp_clock_index(pf); in ice_ptp_release()
2788 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
2789 pf->ptp.clock = NULL; in ice_ptp_release()
2791 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()