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()
508 static int ice_ptp_update_cached_phctime(struct ice_pf *pf) in ice_ptp_update_cached_phctime() argument
513 if (test_and_set_bit(ICE_CFG_BUSY, pf->state)) in ice_ptp_update_cached_phctime()
517 systime = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_update_cached_phctime()
520 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
522 ice_for_each_vsi(pf, i) { in ice_ptp_update_cached_phctime()
523 struct ice_vsi *vsi = pf->vsi[i]; in ice_ptp_update_cached_phctime()
538 clear_bit(ICE_CFG_BUSY, pf->state); in ice_ptp_update_cached_phctime()
636 static u64 ice_ptp_extend_40b_ts(struct ice_pf *pf, u64 in_tstamp) in ice_ptp_extend_40b_ts() argument
640 return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, in ice_ptp_extend_40b_ts()
656 ice_ptp_read_time(struct ice_pf *pf, struct timespec64 *ts, in ice_ptp_read_time() argument
659 u64 time_ns = ice_ptp_read_src_clk_reg(pf, sts); in ice_ptp_read_time()
671 static int ice_ptp_write_init(struct ice_pf *pf, struct timespec64 *ts) in ice_ptp_write_init() argument
674 struct ice_hw *hw = &pf->hw; in ice_ptp_write_init()
687 static int ice_ptp_write_adj(struct ice_pf *pf, s32 adj) in ice_ptp_write_adj() argument
689 struct ice_hw *hw = &pf->hw; in ice_ptp_write_adj()
703 static u64 ice_base_incval(struct ice_pf *pf) in ice_base_incval() argument
705 struct ice_hw *hw = &pf->hw; in ice_base_incval()
715 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
726 static void ice_ptp_reset_ts_memory_quad(struct ice_pf *pf, int quad) in ice_ptp_reset_ts_memory_quad() argument
728 struct ice_hw *hw = &pf->hw; in ice_ptp_reset_ts_memory_quad()
742 struct ice_pf *pf; in ice_ptp_check_tx_fifo() local
747 pf = ptp_port_to_pf(port); in ice_ptp_check_tx_fifo()
748 hw = &pf->hw; in ice_ptp_check_tx_fifo()
762 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
779 dev_dbg(ice_pf_to_dev(pf), "Try %d, port %d FIFO not empty\n", in ice_ptp_check_tx_fifo()
783 dev_dbg(ice_pf_to_dev(pf), in ice_ptp_check_tx_fifo()
786 ice_ptp_reset_ts_memory_quad(pf, quad); in ice_ptp_check_tx_fifo()
804 struct ice_pf *pf = ptp_port_to_pf(port); in ice_ptp_check_tx_offset_valid() local
805 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_check_tx_offset_valid()
806 struct ice_hw *hw = &pf->hw; in ice_ptp_check_tx_offset_valid()
838 struct ice_pf *pf = ptp_port_to_pf(port); in ice_ptp_check_rx_offset_valid() local
839 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_check_rx_offset_valid()
840 struct ice_hw *hw = &pf->hw; in ice_ptp_check_rx_offset_valid()
895 struct ice_pf *pf; in ice_ptp_wait_for_offset_valid() local
899 pf = ptp_port_to_pf(port); in ice_ptp_wait_for_offset_valid()
900 hw = &pf->hw; in ice_ptp_wait_for_offset_valid()
901 dev = ice_pf_to_dev(pf); in ice_ptp_wait_for_offset_valid()
905 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offset_valid()
927 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_stop() local
929 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_stop()
941 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
960 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_restart() local
962 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_restart()
987 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0); in ice_ptp_port_phy_restart()
991 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1005 int ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) in ice_ptp_link_change() argument
1009 if (!test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_ptp_link_change()
1015 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1022 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_link_change()
1033 static void ice_ptp_reset_ts_memory(struct ice_pf *pf) in ice_ptp_reset_ts_memory() argument
1037 quad = pf->hw.port_info->lport / ICE_PORTS_PER_QUAD; in ice_ptp_reset_ts_memory()
1038 ice_ptp_reset_ts_memory_quad(pf, quad); in ice_ptp_reset_ts_memory()
1049 static int ice_ptp_tx_ena_intr(struct ice_pf *pf, bool ena, u32 threshold) in ice_ptp_tx_ena_intr() argument
1051 struct ice_hw *hw = &pf->hw; in ice_ptp_tx_ena_intr()
1056 ice_ptp_reset_ts_memory(pf); in ice_ptp_tx_ena_intr()
1080 dev_err(ice_pf_to_dev(pf), "PTP failed in intr ena, err %d\n", in ice_ptp_tx_ena_intr()
1089 static void ice_ptp_reset_phy_timestamping(struct ice_pf *pf) in ice_ptp_reset_phy_timestamping() argument
1091 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1104 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjfine() local
1106 struct ice_hw *hw = &pf->hw; in ice_ptp_adjfine()
1111 incval = ice_base_incval(pf); in ice_ptp_adjfine()
1136 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1153 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_extts_work() local
1155 struct ice_hw *hw = &pf->hw; in ice_ptp_extts_work()
1167 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_work()
1175 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_work()
1176 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_work()
1190 ice_ptp_cfg_extts(struct ice_pf *pf, bool ena, unsigned int chan, u32 gpio_pin, in ice_ptp_cfg_extts() argument
1194 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_extts()
1197 if (chan > (unsigned int)pf->ptp.info.n_ext_ts) in ice_ptp_cfg_extts()
1225 pf->ptp.ext_ts_chan |= (1 << chan); in ice_ptp_cfg_extts()
1230 pf->ptp.ext_ts_chan &= ~(1 << chan); in ice_ptp_cfg_extts()
1231 if (!pf->ptp.ext_ts_chan) in ice_ptp_cfg_extts()
1252 static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan, in ice_ptp_cfg_clkout() argument
1256 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_clkout()
1274 gpio_pin = pf->ptp.perout_channels[chan].gpio_pin; in ice_ptp_cfg_clkout()
1279 memset(&pf->ptp.perout_channels[chan], 0, in ice_ptp_cfg_clkout()
1291 dev_err(ice_pf_to_dev(pf), "CLK Period must be an even value\n"); in ice_ptp_cfg_clkout()
1301 dev_err(ice_pf_to_dev(pf), "CLK Period must be > %d && < 2^33", in ice_ptp_cfg_clkout()
1309 current_time = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_cfg_clkout()
1339 memcpy(&pf->ptp.perout_channels[chan], config, in ice_ptp_cfg_clkout()
1341 pf->ptp.perout_channels[chan].start_time = phase; in ice_ptp_cfg_clkout()
1346 dev_err(ice_pf_to_dev(pf), "PTP failed to cfg per_clk\n"); in ice_ptp_cfg_clkout()
1358 static void ice_ptp_disable_all_clkout(struct ice_pf *pf) in ice_ptp_disable_all_clkout() argument
1362 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_clkout()
1363 if (pf->ptp.perout_channels[i].ena) in ice_ptp_disable_all_clkout()
1364 ice_ptp_cfg_clkout(pf, i, NULL, false); in ice_ptp_disable_all_clkout()
1375 static void ice_ptp_enable_all_clkout(struct ice_pf *pf) in ice_ptp_enable_all_clkout() argument
1379 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_clkout()
1380 if (pf->ptp.perout_channels[i].ena) in ice_ptp_enable_all_clkout()
1381 ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], in ice_ptp_enable_all_clkout()
1395 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gpio_enable_e810() local
1402 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) in ice_ptp_gpio_enable_e810()
1415 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1432 err = ice_ptp_cfg_clkout(pf, chan, &clk_cfg, true); in ice_ptp_gpio_enable_e810()
1441 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1450 err = ice_ptp_cfg_extts(pf, !!on, chan, gpio_pin, in ice_ptp_gpio_enable_e810()
1474 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gettimex64() local
1475 struct ice_hw *hw = &pf->hw; in ice_ptp_gettimex64()
1478 dev_err(ice_pf_to_dev(pf), "PTP failed to get time\n"); in ice_ptp_gettimex64()
1482 ice_ptp_read_time(pf, ts, sts); in ice_ptp_gettimex64()
1499 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_settime64() local
1501 struct ice_hw *hw = &pf->hw; in ice_ptp_settime64()
1507 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1508 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_settime64()
1516 ice_ptp_disable_all_clkout(pf); in ice_ptp_settime64()
1518 err = ice_ptp_write_init(pf, &ts64); in ice_ptp_settime64()
1522 ice_ptp_update_cached_phctime(pf); in ice_ptp_settime64()
1525 ice_ptp_enable_all_clkout(pf); in ice_ptp_settime64()
1528 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1529 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_settime64()
1532 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
1565 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjtime() local
1566 struct ice_hw *hw = &pf->hw; in ice_ptp_adjtime()
1570 dev = ice_pf_to_dev(pf); in ice_ptp_adjtime()
1587 ice_ptp_disable_all_clkout(pf); in ice_ptp_adjtime()
1589 err = ice_ptp_write_adj(pf, delta); in ice_ptp_adjtime()
1592 ice_ptp_enable_all_clkout(pf); in ice_ptp_adjtime()
1601 ice_ptp_update_cached_phctime(pf); in ice_ptp_adjtime()
1621 struct ice_pf *pf = (struct ice_pf *)ctx; in ice_ptp_get_syncdevicetime() local
1622 struct ice_hw *hw = &pf->hw; in ice_ptp_get_syncdevicetime()
1629 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
1694 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_getcrosststamp_e822() local
1697 pf, NULL, cts); in ice_ptp_getcrosststamp_e822()
1708 int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_get_ts_config() argument
1712 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_get_ts_config()
1715 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
1727 ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) in ice_ptp_set_timestamp_mode() argument
1731 ice_set_tx_tstamp(pf, false); in ice_ptp_set_timestamp_mode()
1734 ice_set_tx_tstamp(pf, true); in ice_ptp_set_timestamp_mode()
1742 ice_set_rx_tstamp(pf, false); in ice_ptp_set_timestamp_mode()
1758 ice_set_rx_tstamp(pf, true); in ice_ptp_set_timestamp_mode()
1774 int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_set_ts_config() argument
1779 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_set_ts_config()
1785 err = ice_ptp_set_timestamp_mode(pf, &config); in ice_ptp_set_ts_config()
1790 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
1841 ice_ptp_disable_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_disable_sma_pins_e810t() argument
1843 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_disable_sma_pins_e810t()
1864 ice_ptp_setup_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_sma_pins_e810t() argument
1866 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_setup_sma_pins_e810t()
1873 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
1878 err = ice_get_sma_config_e810t(&pf->hw, info->pin_config); in ice_ptp_setup_sma_pins_e810t()
1880 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
1889 ice_ptp_setup_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_pins_e810t() argument
1892 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL) && in ice_ptp_setup_pins_e810t()
1893 !ice_is_pca9575_present(&pf->hw)) in ice_ptp_setup_pins_e810t()
1894 ice_clear_feature_support(pf, ICE_F_SMA_CTRL); in ice_ptp_setup_pins_e810t()
1896 if (!ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) { in ice_ptp_setup_pins_e810t()
1908 ice_ptp_setup_sma_pins_e810t(pf, info); in ice_ptp_setup_pins_e810t()
1932 ice_ptp_set_funcs_e822(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e822() argument
1952 ice_ptp_set_funcs_e810(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e810() argument
1956 if (ice_is_e810t(&pf->hw)) in ice_ptp_set_funcs_e810()
1957 ice_ptp_setup_pins_e810t(pf, info); in ice_ptp_set_funcs_e810()
1966 static void ice_ptp_set_caps(struct ice_pf *pf) in ice_ptp_set_caps() argument
1968 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
1969 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_set_caps()
1980 if (ice_is_e810(&pf->hw)) in ice_ptp_set_caps()
1981 ice_ptp_set_funcs_e810(pf, info); in ice_ptp_set_caps()
1983 ice_ptp_set_funcs_e822(pf, info); in ice_ptp_set_caps()
1995 static long ice_ptp_create_clock(struct ice_pf *pf) in ice_ptp_create_clock() argument
2002 if (pf->ptp.clock) in ice_ptp_create_clock()
2005 ice_ptp_set_caps(pf); in ice_ptp_create_clock()
2007 info = &pf->ptp.info; in ice_ptp_create_clock()
2008 dev = ice_pf_to_dev(pf); in ice_ptp_create_clock()
2015 pf->ptp.clock = clock; in ice_ptp_create_clock()
2058 struct ice_pf *pf; in ice_ptp_tx_tstamp_work() local
2067 pf = ptp_port_to_pf(ptp_port); in ice_ptp_tx_tstamp_work()
2068 hw = &pf->hw; in ice_ptp_tx_tstamp_work()
2108 tstamp = ice_ptp_extend_40b_ts(pf, raw_tstamp); in ice_ptp_tx_tstamp_work()
2122 kthread_queue_work(pf->ptp.kworker, &tx->work); in ice_ptp_tx_tstamp_work()
2172 void ice_ptp_process_ts(struct ice_pf *pf) in ice_ptp_process_ts() argument
2174 if (pf->ptp.port.tx.init) in ice_ptp_process_ts()
2175 kthread_queue_work(pf->ptp.kworker, &pf->ptp.port.tx.work); in ice_ptp_process_ts()
2213 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
2229 if (!pf->hw.reset_ongoing) in ice_ptp_flush_tx_tracker()
2230 ice_clear_phy_tstamp(&pf->hw, tx->quad, phy_idx); in ice_ptp_flush_tx_tracker()
2242 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
2248 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
2271 ice_ptp_init_tx_e822(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) in ice_ptp_init_tx_e822() argument
2289 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
2291 tx->quad = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
2342 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work() local
2345 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_periodic_work()
2348 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_periodic_work()
2350 ice_ptp_tx_tstamp_cleanup(&pf->hw, &pf->ptp.port.tx); in ice_ptp_periodic_work()
2361 void ice_ptp_reset(struct ice_pf *pf) in ice_ptp_reset() argument
2363 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_reset()
2364 struct ice_hw *hw = &pf->hw; in ice_ptp_reset()
2369 if (test_bit(ICE_PFR_REQ, pf->state)) in ice_ptp_reset()
2386 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_reset()
2402 err = ice_ptp_write_init(pf, &ts); in ice_ptp_reset()
2413 err = ice_ptp_tx_ena_intr(pf, true, itr); in ice_ptp_reset()
2420 ice_ptp_reset_phy_timestamping(pf); in ice_ptp_reset()
2424 if (ice_is_e810(&pf->hw)) { in ice_ptp_reset()
2425 err = ice_ptp_init_tx_e810(pf, &ptp->port.tx); in ice_ptp_reset()
2429 err = ice_ptp_init_tx_e822(pf, &ptp->port.tx, in ice_ptp_reset()
2435 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_reset()
2440 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_reset()
2444 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_reset()
2451 void ice_ptp_prepare_for_reset(struct ice_pf *pf) in ice_ptp_prepare_for_reset() argument
2453 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset()
2456 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_prepare_for_reset()
2459 ice_ptp_cfg_timestamp(pf, false); in ice_ptp_prepare_for_reset()
2464 if (test_bit(ICE_PFR_REQ, pf->state)) in ice_ptp_prepare_for_reset()
2467 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2470 ice_ptp_disable_all_clkout(pf); in ice_ptp_prepare_for_reset()
2472 src_tmr = ice_get_ptp_src_clock_index(&pf->hw); in ice_ptp_prepare_for_reset()
2475 wr32(&pf->hw, GLTSYN_ENA(src_tmr), (u32)~GLTSYN_ENA_TSYN_ENA_M); in ice_ptp_prepare_for_reset()
2489 static int ice_ptp_init_owner(struct ice_pf *pf) in ice_ptp_init_owner() argument
2491 struct ice_hw *hw = &pf->hw; in ice_ptp_init_owner()
2497 dev_err(ice_pf_to_dev(pf), "Failed to initialize PHC, err %d\n", in ice_ptp_init_owner()
2509 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_init_owner()
2517 err = ice_ptp_write_init(pf, &ts); in ice_ptp_init_owner()
2528 err = ice_ptp_tx_ena_intr(pf, true, itr); in ice_ptp_init_owner()
2534 err = ice_ptp_create_clock(pf); in ice_ptp_init_owner()
2539 ice_set_ptp_clock_index(pf); in ice_ptp_init_owner()
2544 pf->ptp.clock = NULL; in ice_ptp_init_owner()
2554 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
2566 dev_name(ice_pf_to_dev(pf))); in ice_ptp_init_work()
2583 static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) in ice_ptp_init_port() argument
2587 if (ice_is_e810(&pf->hw)) in ice_ptp_init_port()
2588 return ice_ptp_init_tx_e810(pf, &ptp_port->tx); in ice_ptp_init_port()
2592 return ice_ptp_init_tx_e822(pf, &ptp_port->tx, ptp_port->port_num); in ice_ptp_init_port()
2607 void ice_ptp_init(struct ice_pf *pf) in ice_ptp_init() argument
2609 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init()
2610 struct ice_hw *hw = &pf->hw; in ice_ptp_init()
2617 err = ice_ptp_init_owner(pf); in ice_ptp_init()
2623 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
2628 ice_ptp_reset_phy_timestamping(pf); in ice_ptp_init()
2630 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
2631 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
2635 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
2640 if (pf->ptp.clock) { in ice_ptp_init()
2642 pf->ptp.clock = NULL; in ice_ptp_init()
2644 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
2645 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
2655 void ice_ptp_release(struct ice_pf *pf) in ice_ptp_release() argument
2657 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_release()
2661 ice_ptp_cfg_timestamp(pf, false); in ice_ptp_release()
2663 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
2665 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_release()
2667 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
2669 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
2670 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
2671 if (pf->ptp.kworker) { in ice_ptp_release()
2672 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
2673 pf->ptp.kworker = NULL; in ice_ptp_release()
2676 if (!pf->ptp.clock) in ice_ptp_release()
2680 ice_ptp_disable_all_clkout(pf); in ice_ptp_release()
2682 ice_clear_ptp_clock_index(pf); in ice_ptp_release()
2683 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
2684 pf->ptp.clock = NULL; in ice_ptp_release()
2686 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()