Skip to content

Commit cfe209c

Browse files
committed
dpll: zl3073x: Add support to get/set priority on input pins
jira KERNEL-318 Rebuild_History Non-Buildable kernel-6.12.0-124.20.1.el10_1 commit-author Ivan Vecera <ivecera@redhat.com> commit 12ba92f Add support for getting and setting input pin priority. Implement required callbacks and set appropriate capability for input pins. Although the pin priority make sense only if the DPLL is running in automatic mode we have to expose this capability unconditionally because input pins (references) are shared between all DPLLs where one of them can run in automatic mode while the other one not. Co-developed-by: Prathosh Satish <Prathosh.Satish@microchip.com> Signed-off-by: Prathosh Satish <Prathosh.Satish@microchip.com> Signed-off-by: Ivan Vecera <ivecera@redhat.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Link: https://patch.msgid.link/20250704182202.1641943-11-ivecera@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 12ba92f) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 951e375 commit cfe209c

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

drivers/dpll/zl3073x/dpll.c

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,56 @@ zl3073x_dpll_ref_prio_get(struct zl3073x_dpll_pin *pin, u8 *prio)
287287
return rc;
288288
}
289289

290+
/**
291+
* zl3073x_dpll_ref_prio_set - set priority for given input pin
292+
* @pin: pointer to pin
293+
* @prio: place to store priority
294+
*
295+
* Sets priority for the given input pin.
296+
*
297+
* Return: 0 on success, <0 on error
298+
*/
299+
static int
300+
zl3073x_dpll_ref_prio_set(struct zl3073x_dpll_pin *pin, u8 prio)
301+
{
302+
struct zl3073x_dpll *zldpll = pin->dpll;
303+
struct zl3073x_dev *zldev = zldpll->dev;
304+
u8 ref, ref_prio;
305+
int rc;
306+
307+
guard(mutex)(&zldev->multiop_lock);
308+
309+
/* Read DPLL configuration into mailbox */
310+
rc = zl3073x_mb_op(zldev, ZL_REG_DPLL_MB_SEM, ZL_DPLL_MB_SEM_RD,
311+
ZL_REG_DPLL_MB_MASK, BIT(zldpll->id));
312+
if (rc)
313+
return rc;
314+
315+
/* Read reference priority - one value shared between P&N pins */
316+
ref = zl3073x_input_pin_ref_get(pin->id);
317+
rc = zl3073x_read_u8(zldev, ZL_REG_DPLL_REF_PRIO(ref / 2), &ref_prio);
318+
if (rc)
319+
return rc;
320+
321+
/* Update nibble according pin type */
322+
if (zl3073x_dpll_is_p_pin(pin)) {
323+
ref_prio &= ~ZL_DPLL_REF_PRIO_REF_P;
324+
ref_prio |= FIELD_PREP(ZL_DPLL_REF_PRIO_REF_P, prio);
325+
} else {
326+
ref_prio &= ~ZL_DPLL_REF_PRIO_REF_N;
327+
ref_prio |= FIELD_PREP(ZL_DPLL_REF_PRIO_REF_N, prio);
328+
}
329+
330+
/* Update reference priority */
331+
rc = zl3073x_write_u8(zldev, ZL_REG_DPLL_REF_PRIO(ref / 2), ref_prio);
332+
if (rc)
333+
return rc;
334+
335+
/* Commit configuration */
336+
return zl3073x_mb_op(zldev, ZL_REG_DPLL_MB_SEM, ZL_DPLL_MB_SEM_WR,
337+
ZL_REG_DPLL_MB_MASK, BIT(zldpll->id));
338+
}
339+
290340
/**
291341
* zl3073x_dpll_ref_state_get - get status for given input pin
292342
* @pin: pointer to pin
@@ -400,6 +450,42 @@ zl3073x_dpll_input_pin_state_on_dpll_set(const struct dpll_pin *dpll_pin,
400450
return rc;
401451
}
402452

453+
static int
454+
zl3073x_dpll_input_pin_prio_get(const struct dpll_pin *dpll_pin, void *pin_priv,
455+
const struct dpll_device *dpll, void *dpll_priv,
456+
u32 *prio, struct netlink_ext_ack *extack)
457+
{
458+
struct zl3073x_dpll_pin *pin = pin_priv;
459+
460+
*prio = pin->prio;
461+
462+
return 0;
463+
}
464+
465+
static int
466+
zl3073x_dpll_input_pin_prio_set(const struct dpll_pin *dpll_pin, void *pin_priv,
467+
const struct dpll_device *dpll, void *dpll_priv,
468+
u32 prio, struct netlink_ext_ack *extack)
469+
{
470+
struct zl3073x_dpll_pin *pin = pin_priv;
471+
int rc;
472+
473+
if (prio > ZL_DPLL_REF_PRIO_MAX)
474+
return -EINVAL;
475+
476+
/* If the pin is selectable then update HW registers */
477+
if (pin->selectable) {
478+
rc = zl3073x_dpll_ref_prio_set(pin, prio);
479+
if (rc)
480+
return rc;
481+
}
482+
483+
/* Save priority */
484+
pin->prio = prio;
485+
486+
return 0;
487+
}
488+
403489
static int
404490
zl3073x_dpll_output_pin_state_on_dpll_get(const struct dpll_pin *dpll_pin,
405491
void *pin_priv,
@@ -493,6 +579,8 @@ zl3073x_dpll_mode_get(const struct dpll_device *dpll, void *dpll_priv,
493579

494580
static const struct dpll_pin_ops zl3073x_dpll_input_pin_ops = {
495581
.direction_get = zl3073x_dpll_pin_direction_get,
582+
.prio_get = zl3073x_dpll_input_pin_prio_get,
583+
.prio_set = zl3073x_dpll_input_pin_prio_set,
496584
.state_on_dpll_get = zl3073x_dpll_input_pin_state_on_dpll_get,
497585
.state_on_dpll_set = zl3073x_dpll_input_pin_state_on_dpll_set,
498586
};

drivers/dpll/zl3073x/prop.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ struct zl3073x_pin_props *zl3073x_pin_props_get(struct zl3073x_dev *zldev,
205205
if (dir == DPLL_PIN_DIRECTION_INPUT) {
206206
props->dpll_props.type = DPLL_PIN_TYPE_EXT;
207207
props->dpll_props.capabilities =
208+
DPLL_PIN_CAPABILITIES_PRIORITY_CAN_CHANGE |
208209
DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE;
209210
} else {
210211
props->dpll_props.type = DPLL_PIN_TYPE_GNSS;

0 commit comments

Comments
 (0)