Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dpll: add phase-adjust-gran pin attribute

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>

authored by

Ivan Vecera and committed by
Jakub Kicinski
30176bf7 29f7ae9e

+40 -17
+20 -16
Documentation/driver-api/dpll.rst
··· 198 198 ================================== ====================================== 199 199 200 200 Device may also provide ability to adjust a signal phase on a pin. 201 - If pin phase adjustment is supported, minimal and maximal values that pin 202 - handle shall be provide to the user on ``DPLL_CMD_PIN_GET`` respond 203 - with ``DPLL_A_PIN_PHASE_ADJUST_MIN`` and ``DPLL_A_PIN_PHASE_ADJUST_MAX`` 201 + If pin phase adjustment is supported, minimal and maximal values and 202 + granularity that pin handle shall be provided to the user on 203 + ``DPLL_CMD_PIN_GET`` respond with ``DPLL_A_PIN_PHASE_ADJUST_MIN``, 204 + ``DPLL_A_PIN_PHASE_ADJUST_MAX`` and ``DPLL_A_PIN_PHASE_ADJUST_GRAN`` 204 205 attributes. Configured phase adjust value is provided with 205 206 ``DPLL_A_PIN_PHASE_ADJUST`` attribute of a pin, and value change can be 206 207 requested with the same attribute with ``DPLL_CMD_PIN_SET`` command. 207 208 208 - =============================== ====================================== 209 - ``DPLL_A_PIN_ID`` configured pin id 210 - ``DPLL_A_PIN_PHASE_ADJUST_MIN`` attr minimum value of phase adjustment 211 - ``DPLL_A_PIN_PHASE_ADJUST_MAX`` attr maximum value of phase adjustment 212 - ``DPLL_A_PIN_PHASE_ADJUST`` attr configured value of phase 213 - adjustment on parent dpll device 214 - ``DPLL_A_PIN_PARENT_DEVICE`` nested attribute for requesting 215 - configuration on given parent dpll 216 - device 217 - ``DPLL_A_PIN_PARENT_ID`` parent dpll device id 218 - ``DPLL_A_PIN_PHASE_OFFSET`` attr measured phase difference 219 - between a pin and parent dpll device 220 - =============================== ====================================== 209 + ================================ ========================================== 210 + ``DPLL_A_PIN_ID`` configured pin id 211 + ``DPLL_A_PIN_PHASE_ADJUST_GRAN`` attr granularity of phase adjustment value 212 + ``DPLL_A_PIN_PHASE_ADJUST_MIN`` attr minimum value of phase adjustment 213 + ``DPLL_A_PIN_PHASE_ADJUST_MAX`` attr maximum value of phase adjustment 214 + ``DPLL_A_PIN_PHASE_ADJUST`` attr configured value of phase 215 + adjustment on parent dpll device 216 + ``DPLL_A_PIN_PARENT_DEVICE`` nested attribute for requesting 217 + configuration on given parent dpll 218 + device 219 + ``DPLL_A_PIN_PARENT_ID`` parent dpll device id 220 + ``DPLL_A_PIN_PHASE_OFFSET`` attr measured phase difference 221 + between a pin and parent dpll device 222 + ================================ ========================================== 221 223 222 224 All phase related values are provided in pico seconds, which represents 223 225 time difference between signals phase. The negative value means that ··· 386 384 frequencies 387 385 ``DPLL_A_PIN_ANY_FREQUENCY_MIN`` attr minimum value of frequency 388 386 ``DPLL_A_PIN_ANY_FREQUENCY_MAX`` attr maximum value of frequency 387 + ``DPLL_A_PIN_PHASE_ADJUST_GRAN`` attr granularity of phase 388 + adjustment value 389 389 ``DPLL_A_PIN_PHASE_ADJUST_MIN`` attr minimum value of phase 390 390 adjustment 391 391 ``DPLL_A_PIN_PHASE_ADJUST_MAX`` attr maximum value of phase
+7
Documentation/netlink/specs/dpll.yaml
··· 440 440 doc: | 441 441 Capable pin provides list of pins that can be bound to create a 442 442 reference-sync pin pair. 443 + - 444 + name: phase-adjust-gran 445 + type: u32 446 + doc: | 447 + Granularity of phase adjustment, in picoseconds. The value of 448 + phase adjustment must be a multiple of this granularity. 443 449 444 450 - 445 451 name: pin-parent-device ··· 622 616 - capabilities 623 617 - parent-device 624 618 - parent-pin 619 + - phase-adjust-gran 625 620 - phase-adjust-min 626 621 - phase-adjust-max 627 622 - phase-adjust
+11 -1
drivers/dpll/dpll_netlink.c
··· 637 637 ret = dpll_msg_add_pin_freq(msg, pin, ref, extack); 638 638 if (ret) 639 639 return ret; 640 + if (prop->phase_gran && 641 + nla_put_u32(msg, DPLL_A_PIN_PHASE_ADJUST_GRAN, 642 + prop->phase_gran)) 643 + return -EMSGSIZE; 640 644 if (nla_put_s32(msg, DPLL_A_PIN_PHASE_ADJUST_MIN, 641 645 prop->phase_range.min)) 642 646 return -EMSGSIZE; ··· 1265 1261 if (phase_adj > pin->prop.phase_range.max || 1266 1262 phase_adj < pin->prop.phase_range.min) { 1267 1263 NL_SET_ERR_MSG_ATTR(extack, phase_adj_attr, 1268 - "phase adjust value not supported"); 1264 + "phase adjust value of out range"); 1265 + return -EINVAL; 1266 + } 1267 + if (pin->prop.phase_gran && phase_adj % (s32)pin->prop.phase_gran) { 1268 + NL_SET_ERR_MSG_ATTR_FMT(extack, phase_adj_attr, 1269 + "phase adjust value not multiple of %u", 1270 + pin->prop.phase_gran); 1269 1271 return -EINVAL; 1270 1272 } 1271 1273
+1
include/linux/dpll.h
··· 163 163 u32 freq_supported_num; 164 164 struct dpll_pin_frequency *freq_supported; 165 165 struct dpll_pin_phase_adjust_range phase_range; 166 + u32 phase_gran; 166 167 }; 167 168 168 169 #if IS_ENABLED(CONFIG_DPLL)
+1
include/uapi/linux/dpll.h
··· 251 251 DPLL_A_PIN_ESYNC_FREQUENCY_SUPPORTED, 252 252 DPLL_A_PIN_ESYNC_PULSE, 253 253 DPLL_A_PIN_REFERENCE_SYNC, 254 + DPLL_A_PIN_PHASE_ADJUST_GRAN, 254 255 255 256 __DPLL_A_PIN_MAX, 256 257 DPLL_A_PIN_MAX = (__DPLL_A_PIN_MAX - 1)