]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dpll: zl3073x: Implement input pin state setting in automatic mode
authorIvan Vecera <ivecera@redhat.com>
Fri, 4 Jul 2025 18:22:01 +0000 (20:22 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Jul 2025 02:08:53 +0000 (19:08 -0700)
Implement input pin state setting when the DPLL is running in automatic
mode. Unlike manual mode, the DPLL mode switching is not used here and
the implementation uses special priority value (15) to make the given
pin non-selectable.

When the user sets state of the pin as disconnected the driver
internally sets its priority in HW to 15 that prevents the DPLL to
choose this input pin. Conversely, if the pin status is set to
selectable, the driver sets the pin priority in HW to the original saved
value.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://patch.msgid.link/20250704182202.1641943-12-ivecera@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/dpll/zl3073x/dpll.c

index 406b3e48f25180e2c9c3f04a6c6e9bc93f6335d3..d39094b7cbc88d41dfe02d42cc88613da1b1d367 100644 (file)
@@ -439,6 +439,38 @@ zl3073x_dpll_input_pin_state_on_dpll_set(const struct dpll_pin *dpll_pin,
 
                rc = zl3073x_dpll_selected_ref_set(zldpll, new_ref);
                break;
+
+       case ZL_DPLL_MODE_REFSEL_MODE_AUTO:
+               if (state == DPLL_PIN_STATE_SELECTABLE) {
+                       if (pin->selectable)
+                               return 0; /* Pin is already selectable */
+
+                       /* Restore pin priority in HW */
+                       rc = zl3073x_dpll_ref_prio_set(pin, pin->prio);
+                       if (rc)
+                               return rc;
+
+                       /* Mark pin as selectable */
+                       pin->selectable = true;
+               } else if (state == DPLL_PIN_STATE_DISCONNECTED) {
+                       if (!pin->selectable)
+                               return 0; /* Pin is already disconnected */
+
+                       /* Set pin priority to none in HW */
+                       rc = zl3073x_dpll_ref_prio_set(pin,
+                                                      ZL_DPLL_REF_PRIO_NONE);
+                       if (rc)
+                               return rc;
+
+                       /* Mark pin as non-selectable */
+                       pin->selectable = false;
+               } else {
+                       NL_SET_ERR_MSG(extack,
+                                      "Invalid pin state for automatic mode");
+                       return -EINVAL;
+               }
+               break;
+
        default:
                /* In other modes we cannot change input reference */
                NL_SET_ERR_MSG(extack,