Lines Matching refs:pf
189 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_set_sma_e810t() local
190 struct ice_hw *hw = &pf->hw; in ice_ptp_set_sma_e810t()
260 static void ice_set_tx_tstamp(struct ice_pf *pf, bool on) in ice_set_tx_tstamp() argument
266 vsi = ice_get_main_vsi(pf); in ice_set_tx_tstamp()
278 val = rd32(&pf->hw, PFINT_OICR_ENA); in ice_set_tx_tstamp()
283 wr32(&pf->hw, PFINT_OICR_ENA, val); in ice_set_tx_tstamp()
291 static void ice_set_rx_tstamp(struct ice_pf *pf, bool on) in ice_set_rx_tstamp() argument
296 vsi = ice_get_main_vsi(pf); in ice_set_rx_tstamp()
316 static void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena) in ice_ptp_cfg_timestamp() argument
318 ice_set_tx_tstamp(pf, ena); in ice_ptp_cfg_timestamp()
319 ice_set_rx_tstamp(pf, ena); in ice_ptp_cfg_timestamp()
322 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL; in ice_ptp_cfg_timestamp()
323 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_ON; in ice_ptp_cfg_timestamp()
325 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ice_ptp_cfg_timestamp()
326 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_OFF; 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()
504 static void ice_ptp_update_cached_phctime(struct ice_pf *pf) in ice_ptp_update_cached_phctime() argument
510 systime = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_update_cached_phctime()
513 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
515 ice_for_each_vsi(pf, i) { in ice_ptp_update_cached_phctime()
516 struct ice_vsi *vsi = pf->vsi[i]; in ice_ptp_update_cached_phctime()
626 static u64 ice_ptp_extend_40b_ts(struct ice_pf *pf, u64 in_tstamp) in ice_ptp_extend_40b_ts() argument
630 return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, in ice_ptp_extend_40b_ts()
646 ice_ptp_read_time(struct ice_pf *pf, struct timespec64 *ts, in ice_ptp_read_time() argument
649 u64 time_ns = ice_ptp_read_src_clk_reg(pf, sts); in ice_ptp_read_time()
661 static int ice_ptp_write_init(struct ice_pf *pf, struct timespec64 *ts) in ice_ptp_write_init() argument
664 struct ice_hw *hw = &pf->hw; in ice_ptp_write_init()
677 static int ice_ptp_write_adj(struct ice_pf *pf, s32 adj) in ice_ptp_write_adj() argument
679 struct ice_hw *hw = &pf->hw; in ice_ptp_write_adj()
694 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjfine() local
696 struct ice_hw *hw = &pf->hw; in ice_ptp_adjfine()
726 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
743 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_extts_work() local
745 struct ice_hw *hw = &pf->hw; in ice_ptp_extts_work()
757 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_work()
765 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_work()
766 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_work()
780 ice_ptp_cfg_extts(struct ice_pf *pf, bool ena, unsigned int chan, u32 gpio_pin, in ice_ptp_cfg_extts() argument
784 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_extts()
787 if (chan > (unsigned int)pf->ptp.info.n_ext_ts) in ice_ptp_cfg_extts()
815 pf->ptp.ext_ts_chan |= (1 << chan); in ice_ptp_cfg_extts()
820 pf->ptp.ext_ts_chan &= ~(1 << chan); in ice_ptp_cfg_extts()
821 if (!pf->ptp.ext_ts_chan) in ice_ptp_cfg_extts()
842 static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan, in ice_ptp_cfg_clkout() argument
846 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_clkout()
864 gpio_pin = pf->ptp.perout_channels[chan].gpio_pin; in ice_ptp_cfg_clkout()
869 memset(&pf->ptp.perout_channels[chan], 0, in ice_ptp_cfg_clkout()
881 dev_err(ice_pf_to_dev(pf), "CLK Period must be an even value\n"); in ice_ptp_cfg_clkout()
891 dev_err(ice_pf_to_dev(pf), "CLK Period must be > %d && < 2^33", in ice_ptp_cfg_clkout()
899 current_time = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_cfg_clkout()
926 memcpy(&pf->ptp.perout_channels[chan], config, in ice_ptp_cfg_clkout()
928 pf->ptp.perout_channels[chan].start_time = phase; in ice_ptp_cfg_clkout()
933 dev_err(ice_pf_to_dev(pf), "PTP failed to cfg per_clk\n"); in ice_ptp_cfg_clkout()
945 static void ice_ptp_disable_all_clkout(struct ice_pf *pf) in ice_ptp_disable_all_clkout() argument
949 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_clkout()
950 if (pf->ptp.perout_channels[i].ena) in ice_ptp_disable_all_clkout()
951 ice_ptp_cfg_clkout(pf, i, NULL, false); in ice_ptp_disable_all_clkout()
962 static void ice_ptp_enable_all_clkout(struct ice_pf *pf) in ice_ptp_enable_all_clkout() argument
966 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_clkout()
967 if (pf->ptp.perout_channels[i].ena) in ice_ptp_enable_all_clkout()
968 ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], in ice_ptp_enable_all_clkout()
982 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gpio_enable_e810() local
989 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) in ice_ptp_gpio_enable_e810()
1002 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1019 err = ice_ptp_cfg_clkout(pf, chan, &clk_cfg, true); in ice_ptp_gpio_enable_e810()
1028 } else if (ice_is_e810t(&pf->hw)) { in ice_ptp_gpio_enable_e810()
1037 err = ice_ptp_cfg_extts(pf, !!on, chan, gpio_pin, in ice_ptp_gpio_enable_e810()
1061 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gettimex64() local
1062 struct ice_hw *hw = &pf->hw; in ice_ptp_gettimex64()
1065 dev_err(ice_pf_to_dev(pf), "PTP failed to get time\n"); in ice_ptp_gettimex64()
1069 ice_ptp_read_time(pf, ts, sts); in ice_ptp_gettimex64()
1086 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_settime64() local
1088 struct ice_hw *hw = &pf->hw; in ice_ptp_settime64()
1097 ice_ptp_disable_all_clkout(pf); in ice_ptp_settime64()
1099 err = ice_ptp_write_init(pf, &ts64); in ice_ptp_settime64()
1103 ice_ptp_update_cached_phctime(pf); in ice_ptp_settime64()
1106 ice_ptp_enable_all_clkout(pf); in ice_ptp_settime64()
1109 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
1139 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjtime() local
1140 struct ice_hw *hw = &pf->hw; in ice_ptp_adjtime()
1144 dev = ice_pf_to_dev(pf); in ice_ptp_adjtime()
1161 ice_ptp_disable_all_clkout(pf); in ice_ptp_adjtime()
1163 err = ice_ptp_write_adj(pf, delta); in ice_ptp_adjtime()
1166 ice_ptp_enable_all_clkout(pf); in ice_ptp_adjtime()
1175 ice_ptp_update_cached_phctime(pf); in ice_ptp_adjtime()
1187 int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_get_ts_config() argument
1191 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_get_ts_config()
1194 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
1206 ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) in ice_ptp_set_timestamp_mode() argument
1214 ice_set_tx_tstamp(pf, false); in ice_ptp_set_timestamp_mode()
1217 ice_set_tx_tstamp(pf, true); in ice_ptp_set_timestamp_mode()
1225 ice_set_rx_tstamp(pf, false); in ice_ptp_set_timestamp_mode()
1242 ice_set_rx_tstamp(pf, true); in ice_ptp_set_timestamp_mode()
1258 int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_set_ts_config() argument
1263 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_set_ts_config()
1269 err = ice_ptp_set_timestamp_mode(pf, &config); in ice_ptp_set_ts_config()
1274 pf->ptp.tstamp_config = config; in ice_ptp_set_ts_config()
1325 ice_ptp_disable_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_disable_sma_pins_e810t() argument
1327 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_disable_sma_pins_e810t()
1348 ice_ptp_setup_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_sma_pins_e810t() argument
1350 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_setup_sma_pins_e810t()
1357 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
1362 err = ice_get_sma_config_e810t(&pf->hw, info->pin_config); in ice_ptp_setup_sma_pins_e810t()
1364 ice_ptp_disable_sma_pins_e810t(pf, info); in ice_ptp_setup_sma_pins_e810t()
1373 ice_ptp_setup_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_setup_pins_e810t() argument
1376 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL) && in ice_ptp_setup_pins_e810t()
1377 !ice_is_pca9575_present(&pf->hw)) in ice_ptp_setup_pins_e810t()
1378 ice_clear_feature_support(pf, ICE_F_SMA_CTRL); in ice_ptp_setup_pins_e810t()
1380 if (!ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) { in ice_ptp_setup_pins_e810t()
1392 ice_ptp_setup_sma_pins_e810t(pf, info); in ice_ptp_setup_pins_e810t()
1416 ice_ptp_set_funcs_e810(struct ice_pf *pf, struct ptp_clock_info *info) in ice_ptp_set_funcs_e810() argument
1420 if (ice_is_e810t(&pf->hw)) in ice_ptp_set_funcs_e810()
1421 ice_ptp_setup_pins_e810t(pf, info); in ice_ptp_set_funcs_e810()
1430 static void ice_ptp_set_caps(struct ice_pf *pf) in ice_ptp_set_caps() argument
1432 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
1433 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_set_caps()
1444 ice_ptp_set_funcs_e810(pf, info); in ice_ptp_set_caps()
1456 static long ice_ptp_create_clock(struct ice_pf *pf) in ice_ptp_create_clock() argument
1463 if (pf->ptp.clock) in ice_ptp_create_clock()
1466 ice_ptp_set_caps(pf); in ice_ptp_create_clock()
1468 info = &pf->ptp.info; in ice_ptp_create_clock()
1469 dev = ice_pf_to_dev(pf); in ice_ptp_create_clock()
1476 pf->ptp.clock = clock; in ice_ptp_create_clock()
1519 struct ice_pf *pf; in ice_ptp_tx_tstamp_work() local
1528 pf = ptp_port_to_pf(ptp_port); in ice_ptp_tx_tstamp_work()
1529 hw = &pf->hw; in ice_ptp_tx_tstamp_work()
1565 tstamp = ice_ptp_extend_40b_ts(pf, raw_tstamp); in ice_ptp_tx_tstamp_work()
1577 kthread_queue_work(pf->ptp.kworker, &tx->work); in ice_ptp_tx_tstamp_work()
1626 void ice_ptp_process_ts(struct ice_pf *pf) in ice_ptp_process_ts() argument
1628 if (pf->ptp.port.tx.init) in ice_ptp_process_ts()
1629 kthread_queue_work(pf->ptp.kworker, &pf->ptp.port.tx.work); in ice_ptp_process_ts()
1667 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
1683 if (!pf->hw.reset_ongoing) in ice_ptp_flush_tx_tracker()
1684 ice_clear_phy_tstamp(&pf->hw, tx->quad, phy_idx); in ice_ptp_flush_tx_tracker()
1696 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
1702 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
1722 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
1724 tx->quad = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
1769 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work() local
1771 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_periodic_work()
1774 ice_ptp_update_cached_phctime(pf); in ice_ptp_periodic_work()
1776 ice_ptp_tx_tstamp_cleanup(&pf->ptp.port.tx); in ice_ptp_periodic_work()
1791 static int ice_ptp_init_owner(struct ice_pf *pf) in ice_ptp_init_owner() argument
1793 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_init_owner()
1794 struct ice_hw *hw = &pf->hw; in ice_ptp_init_owner()
1830 err = ice_ptp_write_init(pf, &ts); in ice_ptp_init_owner()
1840 err = ice_ptp_create_clock(pf); in ice_ptp_init_owner()
1845 ice_set_ptp_clock_index(pf); in ice_ptp_init_owner()
1850 pf->ptp.clock = NULL; in ice_ptp_init_owner()
1865 void ice_ptp_init(struct ice_pf *pf) in ice_ptp_init() argument
1867 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_init()
1869 struct ice_hw *hw = &pf->hw; in ice_ptp_init()
1878 err = ice_ptp_init_owner(pf); in ice_ptp_init()
1884 ice_ptp_cfg_timestamp(pf, false); in ice_ptp_init()
1887 ice_ptp_init_tx_e810(pf, &pf->ptp.port.tx); in ice_ptp_init()
1890 kthread_init_delayed_work(&pf->ptp.work, ice_ptp_periodic_work); in ice_ptp_init()
1891 kthread_init_work(&pf->ptp.extts_work, ice_ptp_extts_work); in ice_ptp_init()
1901 pf->ptp.kworker = kworker; in ice_ptp_init()
1903 set_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_init()
1906 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, 0); in ice_ptp_init()
1913 if (pf->ptp.clock) { in ice_ptp_init()
1914 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_init()
1915 pf->ptp.clock = NULL; in ice_ptp_init()
1927 void ice_ptp_release(struct ice_pf *pf) in ice_ptp_release() argument
1929 if (!test_bit(ICE_FLAG_PTP, pf->flags)) in ice_ptp_release()
1933 ice_ptp_cfg_timestamp(pf, false); in ice_ptp_release()
1935 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
1937 clear_bit(ICE_FLAG_PTP, pf->flags); in ice_ptp_release()
1939 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
1941 if (pf->ptp.kworker) { in ice_ptp_release()
1942 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
1943 pf->ptp.kworker = NULL; in ice_ptp_release()
1946 if (!pf->ptp.clock) in ice_ptp_release()
1950 ice_ptp_disable_all_clkout(pf); in ice_ptp_release()
1952 ice_clear_ptp_clock_index(pf); in ice_ptp_release()
1953 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
1954 pf->ptp.clock = NULL; in ice_ptp_release()
1956 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()