dpll: add NCO pin type and zl3073x support
Subsystems (5)
Ivan Vecera
maintainercover dpll: add NCO pin type and zl3073x support
Add a new DPLL_PIN_TYPE_INT_NCO pin type for virtual pins representing the NCO mode of a DPLL and implement support for it in the zl3073x driver.
Patch 1 adds the new pin type to the DPLL netlink spec and UAPI header.
Patch 2 adds a virtual NCO input pin to the zl3073x driver that allows userspace to switch a DPLL channel into NCO mode. The pin reports connected/active state when the channel is in NCO mode and handles the hardware-specific details of mode transitions including automatic df_offset capture and 1PPS phase preservation.
Ivan Vecera (2):
dpll: add DPLL_PIN_TYPE_INT_NCO pin type
dpll: zl3073x: add NCO virtual input pin
Documentation/netlink/specs/dpll.yaml | 12 ++ drivers/dpll/dpll_nl.c | 2 +- drivers/dpll/zl3073x/chan.c | 14 +- drivers/dpll/zl3073x/chan.h | 24 +++ drivers/dpll/zl3073x/core.c | 7 + drivers/dpll/zl3073x/dpll.c | 259 ++++++++++++++++++++++---- drivers/dpll/zl3073x/dpll.h | 2 + drivers/dpll/zl3073x/regs.h | 7 + include/uapi/linux/dpll.h | 4 + 9 files changed, 291 insertions(+), 40 deletions(-)
Signature · 1 line
2.53.0
Ivan Vecera
maintainerPATCH 1/2 dpll: add DPLL_PIN_TYPE_INT_NCO pin type
Add DPLL_PIN_TYPE_INT_NCO pin type for device internal numerically controlled oscillators. When connected as a DPLL input, the DPLL operates in NCO mode where the output frequency is controlled by the host.
Update the fractional-frequency-offset-ppt attribute documentation to note that for INT_NCO pins this attribute represents the DPLL's delta frequency offset.
--- Documentation/netlink/specs/dpll.yaml | 12 ++++++++++++ drivers/dpll/dpll_nl.c | 2 +- include/uapi/linux/dpll.h | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-)
Documentation/netlink/specs/dpll.yaml +12 -0
@@ -162,6 +162,12 @@ definitions: - name: gnss doc: GNSS recovered clock + - + name: int-nco + doc: | + Device internal numerically controlled oscillator. + When connected as a DPLL input, the DPLL operates in NCO mode + where output frequency is controlled by the host. render-max: true - type: enum
@@ -453,6 +459,9 @@ attribute-sets: offset on the media associated with the pin. Inside the pin-parent-device nest it represents the frequency offset between the pin and its parent DPLL device. + For pins of type PIN_TYPE_INT_NCO this attribute represents + the DPLL's current delta frequency offset when the NCO pin + is connected. Value is in PPM (parts per million). This is a lower-precision version of fractional-frequency-offset-ppt.
@@ -499,6 +508,9 @@ attribute-sets: offset on the media associated with the pin. Inside the pin-parent-device nest it represents the frequency offset between the pin and its parent DPLL device. + For pins of type PIN_TYPE_INT_NCO this attribute represents + the DPLL's current delta frequency offset when the NCO pin + is connected. Value is in PPT (parts per trillion, 10^-12). This is a higher-precision version of fractional-frequency-offset.
drivers/dpll/dpll_nl.c +1 -1
@@ -61,7 +61,7 @@ static const struct nla_policy dpll_pin_id_get_nl_policy[DPLL_A_PIN_TYPE + 1] = [DPLL_A_PIN_BOARD_LABEL] = { .type = NLA_NUL_STRING, }, [DPLL_A_PIN_PANEL_LABEL] = { .type = NLA_NUL_STRING, }, [DPLL_A_PIN_PACKAGE_LABEL] = { .type = NLA_NUL_STRING, }, - [DPLL_A_PIN_TYPE] = NLA_POLICY_RANGE(NLA_U32, 1, 5), + [DPLL_A_PIN_TYPE] = NLA_POLICY_RANGE(NLA_U32, 1, 6), };/* DPLL_CMD_PIN_GET - do */
include/uapi/linux/dpll.h +4 -0
@@ -127,6 +127,9 @@ enum dpll_type {* @DPLL_PIN_TYPE_SYNCE_ETH_PORT: ethernet port PHY's recovered clock * @DPLL_PIN_TYPE_INT_OSCILLATOR: device internal oscillator * @DPLL_PIN_TYPE_GNSS: GNSS recovered clock +* @DPLL_PIN_TYPE_INT_NCO: Device internal numerically controlled oscillator. +* When connected as a DPLL input, the DPLL operates in NCO mode where output +* frequency is controlled by the host. */ enum dpll_pin_type {DPLL_PIN_TYPE_MUX =1 ,
@@ -134,6 +137,7 @@ enum dpll_pin_type {DPLL_PIN_TYPE_SYNCE_ETH_PORT ,DPLL_PIN_TYPE_INT_OSCILLATOR ,DPLL_PIN_TYPE_GNSS , +DPLL_PIN_TYPE_INT_NCO ,/* private: */ __DPLL_PIN_TYPE_MAX,
Signature · 1 line
2.53.0
Ivan Vecera
maintainerPATCH 2/2 dpll: zl3073x: add NCO virtual input pin
In reply to Ivan VeceraAdd a virtual NCO (Numerically Controlled Oscillator) input pin that lets userspace switch a DPLL channel into NCO mode. The NCO pin is registered with the new DPLL_PIN_TYPE_INT_NCO type and reports DPLL_PIN_STATE_CONNECTED / ACTIVE when the channel is in NCO mode.
When entering NCO mode the nco_auto_read bit in dpll_ctrl_x causes the hardware to automatically capture the current tracking offset into df_offset. This is refreshed immediately after the mode switch so userspace sees an up-to-date FFO value.
When leaving NCO mode set tod_step_reset and tie_clear in dpll_ctrl_x to preserve the output 1PPS phase. PPS DPLLs set tie_clear=1 to re-align to the new reference; EEC DPLLs set tie_clear=0 to prevent an unwanted TIE write.
--- drivers/dpll/zl3073x/chan.c | 14 +- drivers/dpll/zl3073x/chan.h | 24 ++++ drivers/dpll/zl3073x/core.c | 7 + drivers/dpll/zl3073x/dpll.c | 259 ++++++++++++++++++++++++++++++------ drivers/dpll/zl3073x/dpll.h | 2 + drivers/dpll/zl3073x/regs.h | 7 + 6 files changed, 274 insertions(+), 39 deletions(-)
drivers/dpll/zl3073x/chan.c +13 -1
@@ -71,6 +71,10 @@ int zl3073x_chan_state_fetch(struct zl3073x_dev *zldev, u8 index)struct zl3073x_chan *chan = &zldev->chan[index];int rc, i; + rc =zl3073x_read_u8 (zldev,ZL_REG_DPLL_CTRL (index), &chan->ctrl); +if (rc) +return rc; + rc =zl3073x_read_u8 (zldev,ZL_REG_DPLL_MODE_REFSEL (index), &chan->mode_refsel);if (rc)
@@ -145,7 +149,15 @@ int zl3073x_chan_state_set(struct zl3073x_dev *zldev, u8 index,if (!memcmp (&dchan->cfg, &chan->cfg,sizeof (chan->cfg)))return 0 ; -/* Direct register write for mode_refsel */ +/* Direct register writes for ctrl and mode_refsel */ +if (dchan->ctrl != chan->ctrl) { + rc =zl3073x_write_u8 (zldev,ZL_REG_DPLL_CTRL (index), + chan->ctrl); +if (rc) +return rc; + dchan->ctrl = chan->ctrl; + } +if (dchan->mode_refsel != chan->mode_refsel) { rc =zl3073x_write_u8 (zldev,ZL_REG_DPLL_MODE_REFSEL (index), chan->mode_refsel);
drivers/dpll/zl3073x/chan.h +24 -0
@@ -13,6 +13,7 @@ struct zl3073x_dev;/** * struct zl3073x_chan - DPLL channel state +* @ctrl: DPLL control register value * @mode_refsel: mode and reference selection register value * @ref_prio: reference priority registers (4 bits per ref, P/N packed) * @mon_status: monitor status register value
@@ -21,6 +22,7 @@ struct zl3073x_dev;*/ struct zl3073x_chan { struct_group(cfg, + u8 ctrl;u8 mode_refsel;u8 ref_prio[ZL3073X_NUM_REFS /2 ]; );
@@ -152,6 +154,28 @@ static inline u8 zl3073x_chan_lock_state_get(const struct zl3073x_chan *chan)return FIELD_GET (ZL_DPLL_MON_STATUS_STATE , chan->mon_status); } +/** +* zl3073x_chan_mode_is_auto - check if channel is in automatic mode +* @chan: pointer to channel state +* +* Return: true if channel is in automatic mode, false otherwise +*/ +static inline bool zl3073x_chan_mode_is_auto (const struct zl3073x_chan *chan) +{ +return zl3073x_chan_mode_get (chan) ==ZL_DPLL_MODE_REFSEL_MODE_AUTO ; +} + +/** +* zl3073x_chan_mode_is_nco - check if channel is in NCO mode +* @chan: pointer to channel state +* +* Return: true if channel is in NCO mode, false otherwise +*/ +static inline bool zl3073x_chan_mode_is_nco (const struct zl3073x_chan *chan) +{ +return zl3073x_chan_mode_get (chan) ==ZL_DPLL_MODE_REFSEL_MODE_NCO ; +} +/** * zl3073x_chan_is_ho_ready - check if holdover is ready * @chan: pointer to channel state
drivers/dpll/zl3073x/core.c +7 -0
@@ -572,6 +572,13 @@ zl3073x_dev_chan_states_update(struct zl3073x_dev *zldev)int i, rc;for (i =0 ; i < zldev->info->num_channels; i++) { +const struct zl3073x_chan *chan; + +/* Skip channels in NCO mode - no reference tracking */ + chan =zl3073x_chan_state_get (zldev, i); +if (zl3073x_chan_mode_is_nco (chan)) +continue ; + rc =zl3073x_chan_state_update (zldev, i);if (rc) dev_warn(zldev->dev,
drivers/dpll/zl3073x/dpll.c +221 -38
346 lines not on this page · raw message
drivers/dpll/zl3073x/dpll.h +2 -0
@@ -19,6 +19,7 @@* @ops: DPLL device operations for this instance * @dpll_dev: pointer to registered DPLL device * @tracker: tracking object for the acquired reference +* @type: DPLL type (PPS or EEC) * @lock_status: last saved DPLL lock status * @pins: list of pins * @change_work: device change notification work
@@ -33,6 +34,7 @@ struct zl3073x_dpll {struct dpll_device_ops ops;struct dpll_device *dpll_dev;dpll_tracker tracker; +enum dpll_type type;enum dpll_lock_status lock_status;struct list_head pins;struct work_struct change_work;
drivers/dpll/zl3073x/regs.h +7 -0
@@ -17,6 +17,7 @@#define ZL3073X_NUM_OUTPUT_PINS (ZL3073X_NUM_OUTS * 2)#define ZL3073X_NUM_PINS (ZL3073X_NUM_INPUT_PINS + \ ZL3073X_NUM_OUTPUT_PINS) +#define ZL3073X_NCO_PIN_ID ZL3073X_NUM_PINS/* * Register address structure:
@@ -164,6 +165,12 @@#define ZL_DPLL_MODE_REFSEL_MODE_NCO 4#define ZL_DPLL_MODE_REFSEL_REF GENMASK(7, 4) +#define ZL_REG_DPLL_CTRL (_idx) \ + ZL_REG_IDX(_idx, 5, 0x05, 1, ZL3073X_MAX_CHANNELS, 4) +#define ZL_DPLL_CTRL_TIE_CLEAR BIT(0) +#define ZL_DPLL_CTRL_TOD_STEP_RST BIT(2) +#define ZL_DPLL_CTRL_NCO_AUTO_READ BIT(7) +#define ZL_REG_DPLL_DF_READ (_idx) \ ZL_REG_IDX(_idx, 5, 0x28, 1, ZL3073X_MAX_CHANNELS, 1)#define ZL_DPLL_DF_READ_SEM BIT(4)
Signature · 1 line
2.53.0
Ivan Vecera
maintainerQuoted 15 lines · Ivan Vecera
Add a new
DPLL_PIN_TYPE_INT_NCOpin type for virtual pins representing the NCO mode of a DPLL and implement support for it in the zl3073x driver.Patch 1 adds the new pin type to the DPLL netlink spec and UAPI header.
Patch 2 adds a virtual NCO input pin to the zl3073x driver that allows userspace to switch a DPLL channel into NCO mode. The pin reports connected/active state when the channel is in NCO mode and handles the hardware-specific details of mode transitions including automatic
df_offsetcapture and 1PPS phase preservation.Ivan Vecera (2):
dpll: addDPLL_PIN_TYPE_INT_NCOpin type
dpll: zl3073x: add NCO virtual input pin
Quoted 11 lines
Documentation/netlink/specs/dpll.yaml | 12 ++ drivers/dpll/dpll_nl.c | 2 +- drivers/dpll/zl3073x/chan.c | 14 +- drivers/dpll/zl3073x/chan.h | 24 +++ drivers/dpll/zl3073x/core.c | 7 + drivers/dpll/zl3073x/dpll.c | 259 ++++++++++++++++++++++---- drivers/dpll/zl3073x/dpll.h | 2 + drivers/dpll/zl3073x/regs.h | 7 + include/uapi/linux/dpll.h | 4 + 9 files changed, 291 insertions(+), 40 deletions(-)
Sashiko found some issues... will address them in v2.
Ivan