]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dpll: add phase-adjust-gran pin attribute
authorIvan Vecera <ivecera@redhat.com>
Wed, 29 Oct 2025 15:32:06 +0000 (16:32 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 1 Nov 2025 00:59:17 +0000 (17:59 -0700)
Phase-adjust values are currently limited by a min-max range. Some
hardware requires, for certain pin types, that values be multiples of
a specific granularity, as in the zl3073x driver.

Add a `phase-adjust-gran` pin attribute and an appropriate field in
dpll_pin_properties. If set by the driver, use its value to validate
user-provided phase-adjust values.

Reviewed-by: Michal Schmidt <mschmidt@redhat.com>
Reviewed-by: Petr Oros <poros@redhat.com>
Tested-by: Prathosh Satish <Prathosh.Satish@microchip.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Link: https://patch.msgid.link/20251029153207.178448-2-ivecera@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/driver-api/dpll.rst
Documentation/netlink/specs/dpll.yaml
drivers/dpll/dpll_netlink.c
include/linux/dpll.h
include/uapi/linux/dpll.h

index be1fc643b645e3b80c7e1574de6979be04412227..83118c728ed90c0d02eeb1b2e9d4197732a1fbdb 100644 (file)
@@ -198,26 +198,28 @@ be requested with the same attribute with ``DPLL_CMD_DEVICE_SET`` command.
   ================================== ======================================
 
 Device may also provide ability to adjust a signal phase on a pin.
-If pin phase adjustment is supported, minimal and maximal values that pin
-handle shall be provide to the user on ``DPLL_CMD_PIN_GET`` respond
-with ``DPLL_A_PIN_PHASE_ADJUST_MIN`` and ``DPLL_A_PIN_PHASE_ADJUST_MAX``
+If pin phase adjustment is supported, minimal and maximal values and
+granularity that pin handle shall be provided to the user on
+``DPLL_CMD_PIN_GET`` respond with ``DPLL_A_PIN_PHASE_ADJUST_MIN``,
+``DPLL_A_PIN_PHASE_ADJUST_MAX`` and ``DPLL_A_PIN_PHASE_ADJUST_GRAN``
 attributes. Configured phase adjust value is provided with
 ``DPLL_A_PIN_PHASE_ADJUST`` attribute of a pin, and value change can be
 requested with the same attribute with ``DPLL_CMD_PIN_SET`` command.
 
-  =============================== ======================================
-  ``DPLL_A_PIN_ID``               configured pin id
-  ``DPLL_A_PIN_PHASE_ADJUST_MIN`` attr minimum value of phase adjustment
-  ``DPLL_A_PIN_PHASE_ADJUST_MAX`` attr maximum value of phase adjustment
-  ``DPLL_A_PIN_PHASE_ADJUST``     attr configured value of phase
-                                  adjustment on parent dpll device
-  ``DPLL_A_PIN_PARENT_DEVICE``    nested attribute for requesting
-                                  configuration on given parent dpll
-                                  device
-    ``DPLL_A_PIN_PARENT_ID``      parent dpll device id
-    ``DPLL_A_PIN_PHASE_OFFSET``   attr measured phase difference
-                                  between a pin and parent dpll device
-  =============================== ======================================
+  ================================ ==========================================
+  ``DPLL_A_PIN_ID``                configured pin id
+  ``DPLL_A_PIN_PHASE_ADJUST_GRAN`` attr granularity of phase adjustment value
+  ``DPLL_A_PIN_PHASE_ADJUST_MIN``  attr minimum value of phase adjustment
+  ``DPLL_A_PIN_PHASE_ADJUST_MAX``  attr maximum value of phase adjustment
+  ``DPLL_A_PIN_PHASE_ADJUST``      attr configured value of phase
+                                   adjustment on parent dpll device
+  ``DPLL_A_PIN_PARENT_DEVICE``     nested attribute for requesting
+                                   configuration on given parent dpll
+                                   device
+    ``DPLL_A_PIN_PARENT_ID``       parent dpll device id
+    ``DPLL_A_PIN_PHASE_OFFSET``    attr measured phase difference
+                                   between a pin and parent dpll device
+  ================================ ==========================================
 
 All phase related values are provided in pico seconds, which represents
 time difference between signals phase. The negative value means that
@@ -384,6 +386,8 @@ according to attribute purpose.
                                        frequencies
       ``DPLL_A_PIN_ANY_FREQUENCY_MIN`` attr minimum value of frequency
       ``DPLL_A_PIN_ANY_FREQUENCY_MAX`` attr maximum value of frequency
+    ``DPLL_A_PIN_PHASE_ADJUST_GRAN``   attr granularity of phase
+                                       adjustment value
     ``DPLL_A_PIN_PHASE_ADJUST_MIN``    attr minimum value of phase
                                        adjustment
     ``DPLL_A_PIN_PHASE_ADJUST_MAX``    attr maximum value of phase
index 80728f6f9bc876e98645b67164f281d15280d198..78d0724d7e12ce9ea54a8ecb70b146efcf26c944 100644 (file)
@@ -440,6 +440,12 @@ attribute-sets:
         doc: |
           Capable pin provides list of pins that can be bound to create a
           reference-sync pin pair.
+      -
+        name: phase-adjust-gran
+        type: u32
+        doc: |
+          Granularity of phase adjustment, in picoseconds. The value of
+          phase adjustment must be a multiple of this granularity.
 
   -
     name: pin-parent-device
@@ -616,6 +622,7 @@ operations:
             - capabilities
             - parent-device
             - parent-pin
+            - phase-adjust-gran
             - phase-adjust-min
             - phase-adjust-max
             - phase-adjust
index a4153bcb6dcfe1b6f04ed6226647468de7319f46..64944f601ee5aa1d965f84e4ec5f964bc9e5d6da 100644 (file)
@@ -637,6 +637,10 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
        ret = dpll_msg_add_pin_freq(msg, pin, ref, extack);
        if (ret)
                return ret;
+       if (prop->phase_gran &&
+           nla_put_u32(msg, DPLL_A_PIN_PHASE_ADJUST_GRAN,
+                       prop->phase_gran))
+               return -EMSGSIZE;
        if (nla_put_s32(msg, DPLL_A_PIN_PHASE_ADJUST_MIN,
                        prop->phase_range.min))
                return -EMSGSIZE;
@@ -1261,7 +1265,13 @@ dpll_pin_phase_adj_set(struct dpll_pin *pin, struct nlattr *phase_adj_attr,
        if (phase_adj > pin->prop.phase_range.max ||
            phase_adj < pin->prop.phase_range.min) {
                NL_SET_ERR_MSG_ATTR(extack, phase_adj_attr,
-                                   "phase adjust value not supported");
+                                   "phase adjust value of out range");
+               return -EINVAL;
+       }
+       if (pin->prop.phase_gran && phase_adj % (s32)pin->prop.phase_gran) {
+               NL_SET_ERR_MSG_ATTR_FMT(extack, phase_adj_attr,
+                                       "phase adjust value not multiple of %u",
+                                       pin->prop.phase_gran);
                return -EINVAL;
        }
 
index 25be745bf41f1d93b3dbc919b18914af3bce2348..562f520b23c277fdb749e49fce771dd681df11f4 100644 (file)
@@ -163,6 +163,7 @@ struct dpll_pin_properties {
        u32 freq_supported_num;
        struct dpll_pin_frequency *freq_supported;
        struct dpll_pin_phase_adjust_range phase_range;
+       u32 phase_gran;
 };
 
 #if IS_ENABLED(CONFIG_DPLL)
index ab1725a954d7494954f7a61bf2fc2c47ea86fa64..69d35570ac4f12dc0bab9e2f24531b61f3847909 100644 (file)
@@ -251,6 +251,7 @@ enum dpll_a_pin {
        DPLL_A_PIN_ESYNC_FREQUENCY_SUPPORTED,
        DPLL_A_PIN_ESYNC_PULSE,
        DPLL_A_PIN_REFERENCE_SYNC,
+       DPLL_A_PIN_PHASE_ADJUST_GRAN,
 
        __DPLL_A_PIN_MAX,
        DPLL_A_PIN_MAX = (__DPLL_A_PIN_MAX - 1)