// SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2022, Intel Corporation. */ #include "ice.h" #include "ice_lib.h" #include "ice_trace.h" #include <linux/dpll.h> #define ICE_CGU_STATE_ACQ_ERR_THRESHOLD … #define ICE_DPLL_PIN_IDX_INVALID … #define ICE_DPLL_RCLK_NUM_PER_PF … #define ICE_DPLL_PIN_ESYNC_PULSE_HIGH_PERCENT … #define ICE_DPLL_PIN_GEN_RCLK_FREQ … /** * enum ice_dpll_pin_type - enumerate ice pin types: * @ICE_DPLL_PIN_INVALID: invalid pin type * @ICE_DPLL_PIN_TYPE_INPUT: input pin * @ICE_DPLL_PIN_TYPE_OUTPUT: output pin * @ICE_DPLL_PIN_TYPE_RCLK_INPUT: recovery clock input pin */ enum ice_dpll_pin_type { … }; static const char * const pin_type_name[] = …; static const struct dpll_pin_frequency ice_esync_range[] = …; /** * ice_dpll_is_reset - check if reset is in progress * @pf: private board structure * @extack: error reporting * * If reset is in progress, fill extack with error. * * Return: * * false - no reset in progress * * true - reset in progress */ static bool ice_dpll_is_reset(struct ice_pf *pf, struct netlink_ext_ack *extack) { … } /** * ice_dpll_pin_freq_set - set pin's frequency * @pf: private board structure * @pin: pointer to a pin * @pin_type: type of pin being configured * @freq: frequency to be set * @extack: error reporting * * Set requested frequency on a pin. * * Context: Called under pf->dplls.lock * Return: * * 0 - success * * negative - error on AQ or wrong pin type given */ static int ice_dpll_pin_freq_set(struct ice_pf *pf, struct ice_dpll_pin *pin, enum ice_dpll_pin_type pin_type, const u32 freq, struct netlink_ext_ack *extack) { … } /** * ice_dpll_frequency_set - wrapper for pin callback for set frequency * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: pointer to dpll * @dpll_priv: private data pointer passed on dpll registration * @frequency: frequency to be set * @extack: error reporting * @pin_type: type of pin being configured * * Wraps internal set frequency command on a pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error pin not found or couldn't set in hw */ static int ice_dpll_frequency_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, const u32 frequency, struct netlink_ext_ack *extack, enum ice_dpll_pin_type pin_type) { … } /** * ice_dpll_input_frequency_set - input pin callback for set frequency * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: pointer to dpll * @dpll_priv: private data pointer passed on dpll registration * @frequency: frequency to be set * @extack: error reporting * * Wraps internal set frequency command on a pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - success * * negative - error pin not found or couldn't set in hw */ static int ice_dpll_input_frequency_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u64 frequency, struct netlink_ext_ack *extack) { … } /** * ice_dpll_output_frequency_set - output pin callback for set frequency * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: pointer to dpll * @dpll_priv: private data pointer passed on dpll registration * @frequency: frequency to be set * @extack: error reporting * * Wraps internal set frequency command on a pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - success * * negative - error pin not found or couldn't set in hw */ static int ice_dpll_output_frequency_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u64 frequency, struct netlink_ext_ack *extack) { … } /** * ice_dpll_frequency_get - wrapper for pin callback for get frequency * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: pointer to dpll * @dpll_priv: private data pointer passed on dpll registration * @frequency: on success holds pin's frequency * @extack: error reporting * @pin_type: type of pin being configured * * Wraps internal get frequency command of a pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error pin not found or couldn't get from hw */ static int ice_dpll_frequency_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u64 *frequency, struct netlink_ext_ack *extack, enum ice_dpll_pin_type pin_type) { … } /** * ice_dpll_input_frequency_get - input pin callback for get frequency * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: pointer to dpll * @dpll_priv: private data pointer passed on dpll registration * @frequency: on success holds pin's frequency * @extack: error reporting * * Wraps internal get frequency command of a input pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - success * * negative - error pin not found or couldn't get from hw */ static int ice_dpll_input_frequency_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u64 *frequency, struct netlink_ext_ack *extack) { … } /** * ice_dpll_output_frequency_get - output pin callback for get frequency * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: pointer to dpll * @dpll_priv: private data pointer passed on dpll registration * @frequency: on success holds pin's frequency * @extack: error reporting * * Wraps internal get frequency command of a pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - success * * negative - error pin not found or couldn't get from hw */ static int ice_dpll_output_frequency_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u64 *frequency, struct netlink_ext_ack *extack) { … } /** * ice_dpll_pin_enable - enable a pin on dplls * @hw: board private hw structure * @pin: pointer to a pin * @dpll_idx: dpll index to connect to output pin * @pin_type: type of pin being enabled * @extack: error reporting * * Enable a pin on both dplls. Store current state in pin->flags. * * Context: Called under pf->dplls.lock * Return: * * 0 - OK * * negative - error */ static int ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, u8 dpll_idx, enum ice_dpll_pin_type pin_type, struct netlink_ext_ack *extack) { … } /** * ice_dpll_pin_disable - disable a pin on dplls * @hw: board private hw structure * @pin: pointer to a pin * @pin_type: type of pin being disabled * @extack: error reporting * * Disable a pin on both dplls. Store current state in pin->flags. * * Context: Called under pf->dplls.lock * Return: * * 0 - OK * * negative - error */ static int ice_dpll_pin_disable(struct ice_hw *hw, struct ice_dpll_pin *pin, enum ice_dpll_pin_type pin_type, struct netlink_ext_ack *extack) { … } /** * ice_dpll_pin_state_update - update pin's state * @pf: private board struct * @pin: structure with pin attributes to be updated * @pin_type: type of pin being updated * @extack: error reporting * * Determine pin current state and frequency, then update struct * holding the pin info. For input pin states are separated for each * dpll, for rclk pins states are separated for each parent. * * Context: Called under pf->dplls.lock * Return: * * 0 - OK * * negative - error */ static int ice_dpll_pin_state_update(struct ice_pf *pf, struct ice_dpll_pin *pin, enum ice_dpll_pin_type pin_type, struct netlink_ext_ack *extack) { … } /** * ice_dpll_hw_input_prio_set - set input priority value in hardware * @pf: board private structure * @dpll: ice dpll pointer * @pin: ice pin pointer * @prio: priority value being set on a dpll * @extack: error reporting * * Internal wrapper for setting the priority in the hardware. * * Context: Called under pf->dplls.lock * Return: * * 0 - success * * negative - failure */ static int ice_dpll_hw_input_prio_set(struct ice_pf *pf, struct ice_dpll *dpll, struct ice_dpll_pin *pin, const u32 prio, struct netlink_ext_ack *extack) { … } /** * ice_dpll_lock_status_get - get dpll lock status callback * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @status: on success holds dpll's lock status * @status_error: status error value * @extack: error reporting * * Dpll subsystem callback, provides dpll's lock status. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - failure */ static int ice_dpll_lock_status_get(const struct dpll_device *dpll, void *dpll_priv, enum dpll_lock_status *status, enum dpll_lock_status_error *status_error, struct netlink_ext_ack *extack) { … } /** * ice_dpll_mode_get - get dpll's working mode * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @mode: on success holds current working mode of dpll * @extack: error reporting * * Dpll subsystem callback. Provides working mode of dpll. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - failure */ static int ice_dpll_mode_get(const struct dpll_device *dpll, void *dpll_priv, enum dpll_mode *mode, struct netlink_ext_ack *extack) { … } /** * ice_dpll_pin_state_set - set pin's state on dpll * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @enable: if pin shalll be enabled * @extack: error reporting * @pin_type: type of a pin * * Set pin state on a pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - OK or no change required * * negative - error */ static int ice_dpll_pin_state_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, bool enable, struct netlink_ext_ack *extack, enum ice_dpll_pin_type pin_type) { … } /** * ice_dpll_output_state_set - enable/disable output pin on dpll device * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: dpll being configured * @dpll_priv: private data pointer passed on dpll registration * @state: state of pin to be set * @extack: error reporting * * Dpll subsystem callback. Set given state on output type pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - successfully enabled mode * * negative - failed to enable mode */ static int ice_dpll_output_state_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, enum dpll_pin_state state, struct netlink_ext_ack *extack) { … } /** * ice_dpll_input_state_set - enable/disable input pin on dpll levice * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: dpll being configured * @dpll_priv: private data pointer passed on dpll registration * @state: state of pin to be set * @extack: error reporting * * Dpll subsystem callback. Enables given mode on input type pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - successfully enabled mode * * negative - failed to enable mode */ static int ice_dpll_input_state_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, enum dpll_pin_state state, struct netlink_ext_ack *extack) { … } /** * ice_dpll_pin_state_get - set pin's state on dpll * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @state: on success holds state of the pin * @extack: error reporting * @pin_type: type of questioned pin * * Determine pin state set it on a pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - failed to get state */ static int ice_dpll_pin_state_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, enum dpll_pin_state *state, struct netlink_ext_ack *extack, enum ice_dpll_pin_type pin_type) { … } /** * ice_dpll_output_state_get - get output pin state on dpll device * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @state: on success holds state of the pin * @extack: error reporting * * Dpll subsystem callback. Check state of a pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - success * * negative - failed to get state */ static int ice_dpll_output_state_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, enum dpll_pin_state *state, struct netlink_ext_ack *extack) { … } /** * ice_dpll_input_state_get - get input pin state on dpll device * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @state: on success holds state of the pin * @extack: error reporting * * Dpll subsystem callback. Check state of a input pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - success * * negative - failed to get state */ static int ice_dpll_input_state_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, enum dpll_pin_state *state, struct netlink_ext_ack *extack) { … } /** * ice_dpll_input_prio_get - get dpll's input prio * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @prio: on success - returns input priority on dpll * @extack: error reporting * * Dpll subsystem callback. Handler for getting priority of a input pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - failure */ static int ice_dpll_input_prio_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u32 *prio, struct netlink_ext_ack *extack) { … } /** * ice_dpll_input_prio_set - set dpll input prio * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @prio: input priority to be set on dpll * @extack: error reporting * * Dpll subsystem callback. Handler for setting priority of a input pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - failure */ static int ice_dpll_input_prio_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u32 prio, struct netlink_ext_ack *extack) { … } /** * ice_dpll_input_direction - callback for get input pin direction * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @direction: holds input pin direction * @extack: error reporting * * Dpll subsystem callback. Handler for getting direction of a input pin. * * Return: * * 0 - success */ static int ice_dpll_input_direction(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, enum dpll_pin_direction *direction, struct netlink_ext_ack *extack) { … } /** * ice_dpll_output_direction - callback for get output pin direction * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @direction: holds output pin direction * @extack: error reporting * * Dpll subsystem callback. Handler for getting direction of an output pin. * * Return: * * 0 - success */ static int ice_dpll_output_direction(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, enum dpll_pin_direction *direction, struct netlink_ext_ack *extack) { … } /** * ice_dpll_pin_phase_adjust_get - callback for get pin phase adjust value * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @phase_adjust: on success holds pin phase_adjust value * @extack: error reporting * * Dpll subsystem callback. Handler for getting phase adjust value of a pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_pin_phase_adjust_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, s32 *phase_adjust, struct netlink_ext_ack *extack) { … } /** * ice_dpll_pin_phase_adjust_set - helper for setting a pin phase adjust value * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @phase_adjust: phase_adjust to be set * @extack: error reporting * @type: type of a pin * * Helper for dpll subsystem callback. Handler for setting phase adjust value * of a pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_pin_phase_adjust_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, s32 phase_adjust, struct netlink_ext_ack *extack, enum ice_dpll_pin_type type) { … } /** * ice_dpll_input_phase_adjust_set - callback for set input pin phase adjust * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @phase_adjust: phase_adjust to be set * @extack: error reporting * * Dpll subsystem callback. Wraps a handler for setting phase adjust on input * pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_input_phase_adjust_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, s32 phase_adjust, struct netlink_ext_ack *extack) { … } /** * ice_dpll_output_phase_adjust_set - callback for set output pin phase adjust * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @phase_adjust: phase_adjust to be set * @extack: error reporting * * Dpll subsystem callback. Wraps a handler for setting phase adjust on output * pin. * * Context: Calls a function which acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_output_phase_adjust_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, s32 phase_adjust, struct netlink_ext_ack *extack) { … } #define ICE_DPLL_PHASE_OFFSET_DIVIDER … #define ICE_DPLL_PHASE_OFFSET_FACTOR … /** * ice_dpll_phase_offset_get - callback for get dpll phase shift value * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @phase_offset: on success holds pin phase_offset value * @extack: error reporting * * Dpll subsystem callback. Handler for getting phase shift value between * dpll's input and output. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_phase_offset_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, s64 *phase_offset, struct netlink_ext_ack *extack) { … } /** * ice_dpll_output_esync_set - callback for setting embedded sync * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @freq: requested embedded sync frequency * @extack: error reporting * * Dpll subsystem callback. Handler for setting embedded sync frequency value * on output pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_output_esync_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u64 freq, struct netlink_ext_ack *extack) { … } /** * ice_dpll_output_esync_get - callback for getting embedded sync config * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @esync: on success holds embedded sync pin properties * @extack: error reporting * * Dpll subsystem callback. Handler for getting embedded sync frequency value * and capabilities on output pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_output_esync_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, struct dpll_pin_esync *esync, struct netlink_ext_ack *extack) { … } /** * ice_dpll_input_esync_set - callback for setting embedded sync * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @freq: requested embedded sync frequency * @extack: error reporting * * Dpll subsystem callback. Handler for setting embedded sync frequency value * on input pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_input_esync_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, u64 freq, struct netlink_ext_ack *extack) { … } /** * ice_dpll_input_esync_get - callback for getting embedded sync config * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @esync: on success holds embedded sync pin properties * @extack: error reporting * * Dpll subsystem callback. Handler for getting embedded sync frequency value * and capabilities on input pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - error */ static int ice_dpll_input_esync_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_device *dpll, void *dpll_priv, struct dpll_pin_esync *esync, struct netlink_ext_ack *extack) { … } /** * ice_dpll_rclk_state_on_pin_set - set a state on rclk pin * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @parent_pin: pin parent pointer * @parent_pin_priv: parent private data pointer passed on pin registration * @state: state to be set on pin * @extack: error reporting * * Dpll subsystem callback, set a state of a rclk pin on a parent pin * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - failure */ static int ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv, const struct dpll_pin *parent_pin, void *parent_pin_priv, enum dpll_pin_state state, struct netlink_ext_ack *extack) { … } /** * ice_dpll_rclk_state_on_pin_get - get a state of rclk pin * @pin: pointer to a pin * @pin_priv: private data pointer passed on pin registration * @parent_pin: pin parent pointer * @parent_pin_priv: pin parent priv data pointer passed on pin registration * @state: on success holds pin state on parent pin * @extack: error reporting * * dpll subsystem callback, get a state of a recovered clock pin. * * Context: Acquires pf->dplls.lock * Return: * * 0 - success * * negative - failure */ static int ice_dpll_rclk_state_on_pin_get(const struct dpll_pin *pin, void *pin_priv, const struct dpll_pin *parent_pin, void *parent_pin_priv, enum dpll_pin_state *state, struct netlink_ext_ack *extack) { … } static const struct dpll_pin_ops ice_dpll_rclk_ops = …; static const struct dpll_pin_ops ice_dpll_input_ops = …; static const struct dpll_pin_ops ice_dpll_output_ops = …; static const struct dpll_device_ops ice_dpll_ops = …; /** * ice_generate_clock_id - generates unique clock_id for registering dpll. * @pf: board private structure * * Generates unique (per board) clock_id for allocation and search of dpll * devices in Linux dpll subsystem. * * Return: generated clock id for the board */ static u64 ice_generate_clock_id(struct ice_pf *pf) { … } /** * ice_dpll_notify_changes - notify dpll subsystem about changes * @d: pointer do dpll * * Once change detected appropriate event is submitted to the dpll subsystem. */ static void ice_dpll_notify_changes(struct ice_dpll *d) { … } /** * ice_dpll_update_state - update dpll state * @pf: pf private structure * @d: pointer to queried dpll device * @init: if function called on initialization of ice dpll * * Poll current state of dpll from hw and update ice_dpll struct. * * Context: Called by kworker under pf->dplls.lock * Return: * * 0 - success * * negative - AQ failure */ static int ice_dpll_update_state(struct ice_pf *pf, struct ice_dpll *d, bool init) { … } /** * ice_dpll_periodic_work - DPLLs periodic worker * @work: pointer to kthread_work structure * * DPLLs periodic worker is responsible for polling state of dpll. * Context: Holds pf->dplls.lock */ static void ice_dpll_periodic_work(struct kthread_work *work) { … } /** * ice_dpll_release_pins - release pins resources from dpll subsystem * @pins: pointer to pins array * @count: number of pins * * Release resources of given pins array in the dpll subsystem. */ static void ice_dpll_release_pins(struct ice_dpll_pin *pins, int count) { … } /** * ice_dpll_get_pins - get pins from dpll subsystem * @pf: board private structure * @pins: pointer to pins array * @start_idx: get starts from this pin idx value * @count: number of pins * @clock_id: clock_id of dpll device * * Get pins - allocate - in dpll subsystem, store them in pin field of given * pins array. * * Return: * * 0 - success * * negative - allocation failure reason */ static int ice_dpll_get_pins(struct ice_pf *pf, struct ice_dpll_pin *pins, int start_idx, int count, u64 clock_id) { … } /** * ice_dpll_unregister_pins - unregister pins from a dpll * @dpll: dpll device pointer * @pins: pointer to pins array * @ops: callback ops registered with the pins * @count: number of pins * * Unregister pins of a given array of pins from given dpll device registered in * dpll subsystem. */ static void ice_dpll_unregister_pins(struct dpll_device *dpll, struct ice_dpll_pin *pins, const struct dpll_pin_ops *ops, int count) { … } /** * ice_dpll_register_pins - register pins with a dpll * @dpll: dpll pointer to register pins with * @pins: pointer to pins array * @ops: callback ops registered with the pins * @count: number of pins * * Register pins of a given array with given dpll in dpll subsystem. * * Return: * * 0 - success * * negative - registration failure reason */ static int ice_dpll_register_pins(struct dpll_device *dpll, struct ice_dpll_pin *pins, const struct dpll_pin_ops *ops, int count) { … } /** * ice_dpll_deinit_direct_pins - deinitialize direct pins * @cgu: if cgu is present and controlled by this NIC * @pins: pointer to pins array * @count: number of pins * @ops: callback ops registered with the pins * @first: dpll device pointer * @second: dpll device pointer * * If cgu is owned unregister pins from given dplls. * Release pins resources to the dpll subsystem. */ static void ice_dpll_deinit_direct_pins(bool cgu, struct ice_dpll_pin *pins, int count, const struct dpll_pin_ops *ops, struct dpll_device *first, struct dpll_device *second) { … } /** * ice_dpll_init_direct_pins - initialize direct pins * @pf: board private structure * @cgu: if cgu is present and controlled by this NIC * @pins: pointer to pins array * @start_idx: on which index shall allocation start in dpll subsystem * @count: number of pins * @ops: callback ops registered with the pins * @first: dpll device pointer * @second: dpll device pointer * * Allocate directly connected pins of a given array in dpll subsystem. * If cgu is owned register allocated pins with given dplls. * * Return: * * 0 - success * * negative - registration failure reason */ static int ice_dpll_init_direct_pins(struct ice_pf *pf, bool cgu, struct ice_dpll_pin *pins, int start_idx, int count, const struct dpll_pin_ops *ops, struct dpll_device *first, struct dpll_device *second) { … } /** * ice_dpll_deinit_rclk_pin - release rclk pin resources * @pf: board private structure * * Deregister rclk pin from parent pins and release resources in dpll subsystem. */ static void ice_dpll_deinit_rclk_pin(struct ice_pf *pf) { … } /** * ice_dpll_init_rclk_pins - initialize recovered clock pin * @pf: board private structure * @pin: pin to register * @start_idx: on which index shall allocation start in dpll subsystem * @ops: callback ops registered with the pins * * Allocate resource for recovered clock pin in dpll subsystem. Register the * pin with the parents it has in the info. Register pin with the pf's main vsi * netdev. * * Return: * * 0 - success * * negative - registration failure reason */ static int ice_dpll_init_rclk_pins(struct ice_pf *pf, struct ice_dpll_pin *pin, int start_idx, const struct dpll_pin_ops *ops) { … } /** * ice_dpll_deinit_pins - deinitialize direct pins * @pf: board private structure * @cgu: if cgu is controlled by this pf * * If cgu is owned unregister directly connected pins from the dplls. * Release resources of directly connected pins from the dpll subsystem. */ static void ice_dpll_deinit_pins(struct ice_pf *pf, bool cgu) { … } /** * ice_dpll_init_pins - init pins and register pins with a dplls * @pf: board private structure * @cgu: if cgu is present and controlled by this NIC * * Initialize directly connected pf's pins within pf's dplls in a Linux dpll * subsystem. * * Return: * * 0 - success * * negative - initialization failure reason */ static int ice_dpll_init_pins(struct ice_pf *pf, bool cgu) { … } /** * ice_dpll_deinit_dpll - deinitialize dpll device * @pf: board private structure * @d: pointer to ice_dpll * @cgu: if cgu is present and controlled by this NIC * * If cgu is owned unregister the dpll from dpll subsystem. * Release resources of dpll device from dpll subsystem. */ static void ice_dpll_deinit_dpll(struct ice_pf *pf, struct ice_dpll *d, bool cgu) { … } /** * ice_dpll_init_dpll - initialize dpll device in dpll subsystem * @pf: board private structure * @d: dpll to be initialized * @cgu: if cgu is present and controlled by this NIC * @type: type of dpll being initialized * * Allocate dpll instance for this board in dpll subsystem, if cgu is controlled * by this NIC, register dpll with the callback ops. * * Return: * * 0 - success * * negative - initialization failure reason */ static int ice_dpll_init_dpll(struct ice_pf *pf, struct ice_dpll *d, bool cgu, enum dpll_type type) { … } /** * ice_dpll_deinit_worker - deinitialize dpll kworker * @pf: board private structure * * Stop dpll's kworker, release it's resources. */ static void ice_dpll_deinit_worker(struct ice_pf *pf) { … } /** * ice_dpll_init_worker - Initialize DPLLs periodic worker * @pf: board private structure * * Create and start DPLLs periodic worker. * * Context: Shall be called after pf->dplls.lock is initialized. * Return: * * 0 - success * * negative - create worker failure */ static int ice_dpll_init_worker(struct ice_pf *pf) { … } /** * ice_dpll_init_info_pins_generic - initializes generic pins info * @pf: board private structure * @input: if input pins initialized * * Init information for generic pins, cache them in PF's pins structures. * * Return: * * 0 - success * * negative - init failure reason */ static int ice_dpll_init_info_pins_generic(struct ice_pf *pf, bool input) { … } /** * ice_dpll_init_info_direct_pins - initializes direct pins info * @pf: board private structure * @pin_type: type of pins being initialized * * Init information for directly connected pins, cache them in pf's pins * structures. * * Return: * * 0 - success * * negative - init failure reason */ static int ice_dpll_init_info_direct_pins(struct ice_pf *pf, enum ice_dpll_pin_type pin_type) { … } /** * ice_dpll_init_info_rclk_pin - initializes rclk pin information * @pf: board private structure * * Init information for rclk pin, cache them in pf->dplls.rclk. * * Return: * * 0 - success * * negative - init failure reason */ static int ice_dpll_init_info_rclk_pin(struct ice_pf *pf) { … } /** * ice_dpll_init_pins_info - init pins info wrapper * @pf: board private structure * @pin_type: type of pins being initialized * * Wraps functions for pin initialization. * * Return: * * 0 - success * * negative - init failure reason */ static int ice_dpll_init_pins_info(struct ice_pf *pf, enum ice_dpll_pin_type pin_type) { … } /** * ice_dpll_deinit_info - release memory allocated for pins info * @pf: board private structure * * Release memory allocated for pins by ice_dpll_init_info function. */ static void ice_dpll_deinit_info(struct ice_pf *pf) { … } /** * ice_dpll_init_info - prepare pf's dpll information structure * @pf: board private structure * @cgu: if cgu is present and controlled by this NIC * * Acquire (from HW) and set basic dpll information (on pf->dplls struct). * * Return: * * 0 - success * * negative - init failure reason */ static int ice_dpll_init_info(struct ice_pf *pf, bool cgu) { … } /** * ice_dpll_deinit - Disable the driver/HW support for dpll subsystem * the dpll device. * @pf: board private structure * * Handles the cleanup work required after dpll initialization, freeing * resources and unregistering the dpll, pin and all resources used for * handling them. * * Context: Destroys pf->dplls.lock mutex. Call only if ICE_FLAG_DPLL was set. */ void ice_dpll_deinit(struct ice_pf *pf) { … } /** * ice_dpll_init - initialize support for dpll subsystem * @pf: board private structure * * Set up the device dplls, register them and pins connected within Linux dpll * subsystem. Allow userspace to obtain state of DPLL and handling of DPLL * configuration requests. * * Context: Initializes pf->dplls.lock mutex. */ void ice_dpll_init(struct ice_pf *pf) { … }