Add property to specify the ID of the clock that the DPLL device drives. The ID value represents Unique Clock Identified (EUI-64) defined by IEEE 1588 standard. The property is not mandatory because some DPLL devices can have an ability to read this from HW. The situation is very similar to network controllers without assigned MAC address. Signed-off-by: Ivan Vecera --- Documentation/devicetree/bindings/dpll/dpll-device.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/dpll/dpll-device.yaml b/Documentation/devicetree/bindings/dpll/dpll-device.yaml index fb8d7a9a3693f..8e4ffe8ca279c 100644 --- a/Documentation/devicetree/bindings/dpll/dpll-device.yaml +++ b/Documentation/devicetree/bindings/dpll/dpll-device.yaml @@ -27,6 +27,11 @@ properties: "#size-cells": const: 0 + clock-id: + description: Specifies ID of the clock that the DPLL device drives + $ref: /schemas/types.yaml#/definitions/uint64 + minimum: 1 + dpll-types: description: List of DPLL channel types, one per DPLL instance. $ref: /schemas/types.yaml#/definitions/non-unique-string-array -- 2.49.1 The clock ID value can be specified by the platform via 'clock-id' property. Use this property value to initialize clock ID and if it is not specified generate random one as fallback. Tested-by: Prathosh Satish Signed-off-by: Ivan Vecera --- drivers/dpll/zl3073x/core.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/dpll/zl3073x/core.c b/drivers/dpll/zl3073x/core.c index 7ebcfc5ec1f09..f5245225f1d3b 100644 --- a/drivers/dpll/zl3073x/core.c +++ b/drivers/dpll/zl3073x/core.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include #include @@ -932,6 +934,29 @@ zl3073x_dev_phase_meas_setup(struct zl3073x_dev *zldev, int num_channels) return zl3073x_write_u8(zldev, ZL_REG_DPLL_PHASE_ERR_READ_MASK, mask); } +/** + * zl3073x_dev_clock_id_init - initialize clock ID + * @zldev: pointer to zl3073x device + * + * Initializes clock ID using device property if it is provided or + * generates random one. + */ +static void +zl3073x_dev_clock_id_init(struct zl3073x_dev *zldev) +{ + u64 clock_id; + int rc; + + /* Try to read clock ID from device property */ + rc = device_property_read_u64(zldev->dev, "clock-id", &clock_id); + + /* Generate random id if the property does not exist or value is zero */ + if (rc || !clock_id) + clock_id = get_random_u64(); + + zldev->clock_id = clock_id; +} + /** * zl3073x_dev_probe - initialize zl3073x device * @zldev: pointer to zl3073x device @@ -985,11 +1010,8 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev, FIELD_GET(GENMASK(15, 8), cfg_ver), FIELD_GET(GENMASK(7, 0), cfg_ver)); - /* Generate random clock ID as the device has not such property that - * could be used for this purpose. A user can later change this value - * using devlink. - */ - zldev->clock_id = get_random_u64(); + /* Initialize clock ID */ + zl3073x_dev_clock_id_init(zldev); /* Initialize mutex for operations where multiple reads, writes * and/or polls are required to be done atomically. -- 2.49.1