From: Ivan Vecera <ivecera@redhat.com>
To: netdev@vger.kernel.org
Cc: Prathosh Satish <prathosh.satish@microchip.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
Jiri Pirko <jiri@resnulli.us>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Prathosh Satish <Prathosh.Satish@microchip.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Michal Schmidt <mschmidt@redhat.com>,
Petr Oros <poros@redhat.com>
Subject: [PATCH net-next 2/2] dpll: zl3073x: Initialize clock ID from device property
Date: Thu, 17 Jul 2025 19:11:00 +0200 [thread overview]
Message-ID: <20250717171100.2245998-3-ivecera@redhat.com> (raw)
In-Reply-To: <20250717171100.2245998-1-ivecera@redhat.com>
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 <prathosh.satish@microchip.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
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 <linux/math64.h>
#include <linux/module.h>
#include <linux/netlink.h>
+#include <linux/property.h>
+#include <linux/random.h>
#include <linux/regmap.h>
#include <linux/sprintf.h>
#include <linux/string_choices.h>
@@ -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
prev parent reply other threads:[~2025-07-17 17:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-17 17:10 [PATCH net-next 0/2] dpll: zl3073x: Read clock ID from device property Ivan Vecera
2025-07-17 17:10 ` [PATCH net-next 1/2] dt-bindings: dpll: Add clock ID property Ivan Vecera
2025-07-18 6:55 ` Krzysztof Kozlowski
2025-07-18 12:16 ` Ivan Vecera
2025-07-21 9:23 ` Krzysztof Kozlowski
2025-07-21 12:54 ` Ivan Vecera
2025-07-23 6:25 ` Krzysztof Kozlowski
2025-07-23 7:23 ` Ivan Vecera
2025-08-03 11:12 ` Krzysztof Kozlowski
2025-08-04 18:26 ` Ivan Vecera
2025-08-04 18:45 ` Andrew Lunn
2025-08-05 15:26 ` Ivan Vecera
2025-08-05 15:31 ` Andrew Lunn
2025-07-17 17:11 ` Ivan Vecera [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250717171100.2245998-3-ivecera@redhat.com \
--to=ivecera@redhat.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jiri@resnulli.us \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=poros@redhat.com \
--cc=prathosh.satish@microchip.com \
--cc=robh@kernel.org \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).