From: Ivan Vecera <ivecera@redhat.com>
To: netdev@vger.kernel.org
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
Conor Dooley <conor+dt@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Grzegorz Nitka <grzegorz.nitka@intel.com>,
Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@resnulli.us>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Leon Romanovsky <leon@kernel.org>, Mark Bloch <mbloch@nvidia.com>,
Michal Schmidt <mschmidt@redhat.com>,
Paolo Abeni <pabeni@redhat.com>, Petr Oros <poros@redhat.com>,
Prathosh Satish <Prathosh.Satish@microchip.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Richard Cochran <richardcochran@gmail.com>,
Rob Herring <robh@kernel.org>, Saeed Mahameed <saeedm@nvidia.com>,
Saravana Kannan <saravanak@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
devicetree@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: [PATCH net-next v2 03/12] dpll: Add helpers to find DPLL pin fwnode
Date: Fri, 16 Jan 2026 19:46:01 +0100 [thread overview]
Message-ID: <20260116184610.147591-4-ivecera@redhat.com> (raw)
In-Reply-To: <20260116184610.147591-1-ivecera@redhat.com>
dpll: core: add helpers to find DPLL pin fwnode
Add helper functions to the DPLL core to retrieve a DPLL pin's firmware
node handle based on the 'dpll-pins' and 'dpll-pin-names' properties.
Unlike simple phandle arrays, 'dpll-pins' entries typically contain
a pin specifier (index and direction) as defined by '#dpll-pin-cells'.
The new helper fwnode_dpll_pin_node_get() parses these specifiers
using fwnode_property_get_reference_args(). It resolves the target
pin by:
1. Identifying the DPLL device node from the phandle.
2. Selecting the correct sub-node ('input-pins' or 'output-pins') based
on the direction argument.
3. Matching the pin index argument against the 'reg' property of
the child nodes.
Additionally, register 'dpll-pins' in drivers/of/property.c to enable
proper parsing of the supplier bindings by the OF core.
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
v2:
* added check for fwnode_property_match_string() return value
* reworked searching for the pin using dpll device phandle and
pin specifier
* added dpll-pins into OF core supplier_bindings
---
drivers/dpll/dpll_core.c | 74 ++++++++++++++++++++++++++++++++++++++++
drivers/of/property.c | 2 ++
include/linux/dpll.h | 15 ++++++++
3 files changed, 91 insertions(+)
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index fb68b5e19b480..b0083b5c10aa4 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -13,6 +13,7 @@
#include <linux/property.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <dt-bindings/dpll/dpll.h>
#include "dpll_core.h"
#include "dpll_netlink.h"
@@ -654,6 +655,79 @@ struct dpll_pin *fwnode_dpll_pin_find(struct fwnode_handle *fwnode)
}
EXPORT_SYMBOL_GPL(fwnode_dpll_pin_find);
+/**
+ * fwnode_dpll_pin_node_get - get dpll pin node from given fw node and pin name
+ * @fwnode: firmware node that uses the dpll pin
+ * @name: dpll pin name from dpll-pin-names property
+ *
+ * Return: ERR_PTR() on error or a valid firmware node handle on success.
+ */
+struct fwnode_handle *fwnode_dpll_pin_node_get(struct fwnode_handle *fwnode,
+ const char *name)
+{
+ struct fwnode_handle *parent_node, *pin_node;
+ struct fwnode_reference_args args;
+ const char *parent_name;
+ int ret, index = 0;
+
+ if (name) {
+ index = fwnode_property_match_string(fwnode, "dpll-pin-names",
+ name);
+ if (index < 0)
+ return ERR_PTR(-ENOENT);
+ }
+
+ ret = fwnode_property_get_reference_args(fwnode, "dpll-pins",
+ "#dpll-pin-cells", 2, index,
+ &args);
+ if (ret)
+ return ERR_PTR(ret);
+
+ /* We support only 2 cell DPLL bindings in the kernel currently. */
+ if (args.nargs != 2) {
+ fwnode_handle_put(args.fwnode);
+ return ERR_PTR(-ENOENT);
+ }
+
+ /* Resolve parent node name according pin direction type */
+ switch (args.args[1]) {
+ case DPLL_PIN_INPUT:
+ parent_name = "input-pins";
+ break;
+ case DPLL_PIN_OUTPUT:
+ parent_name = "output-pins";
+ break;
+ default:
+ fwnode_handle_put(args.fwnode);
+ return ERR_PTR(-EINVAL);
+ }
+
+ /* Get pin's parent sub-node */
+ parent_node = fwnode_get_named_child_node(args.fwnode, parent_name);
+ if (!parent_node) {
+ fwnode_handle_put(args.fwnode);
+ return ERR_PTR(-ENOENT);
+ }
+
+ /* Enumerate child pin nodes and find the requested one */
+ fwnode_for_each_child_node(parent_node, pin_node) {
+ u32 reg;
+
+ if (fwnode_property_read_u32(pin_node, "reg", ®))
+ continue;
+
+ if (reg == args.args[0])
+ break;
+ }
+
+ /* Release pin's parent and dpll device node */
+ fwnode_handle_put(parent_node);
+ fwnode_handle_put(args.fwnode);
+
+ return pin_node ? pin_node : ERR_PTR(-ENOENT);
+}
+EXPORT_SYMBOL_GPL(fwnode_dpll_pin_node_get);
+
static int
__dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
const struct dpll_pin_ops *ops, void *priv, void *cookie)
diff --git a/drivers/of/property.c b/drivers/of/property.c
index 4e3524227720a..8571c8bb71ade 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1410,6 +1410,7 @@ DEFINE_SIMPLE_PROP(post_init_providers, "post-init-providers", NULL)
DEFINE_SIMPLE_PROP(access_controllers, "access-controllers", "#access-controller-cells")
DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells")
DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL)
+DEFINE_SIMPLE_PROP(dpll_pins, "dpll-pins", "#dpll-pin-cells")
DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)
DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
@@ -1568,6 +1569,7 @@ static const struct supplier_bindings of_supplier_bindings[] = {
.parse_prop = parse_post_init_providers,
.fwlink_flags = FWLINK_FLAG_IGNORE,
},
+ { .parse_prop = parse_dpll_pins, },
{}
};
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index f0c31a111c304..755c36d1ef45a 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -11,6 +11,7 @@
#include <linux/device.h>
#include <linux/netlink.h>
#include <linux/netdevice.h>
+#include <linux/property.h>
#include <linux/rtnetlink.h>
struct dpll_device;
@@ -176,6 +177,8 @@ int dpll_netdev_add_pin_handle(struct sk_buff *msg,
const struct net_device *dev);
struct dpll_pin *fwnode_dpll_pin_find(struct fwnode_handle *fwnode);
+struct fwnode_handle *fwnode_dpll_pin_node_get(struct fwnode_handle *fwnode,
+ const char *name);
#else
static inline void
dpll_netdev_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin) { }
@@ -197,8 +200,20 @@ fwnode_dpll_pin_find(struct fwnode_handle *fwnode)
{
return NULL;
}
+
+static inline struct fwnode_handle *
+fwnode_dpll_pin_node_get(struct fwnode_handle *fwnode, const char *name)
+{
+ return NULL;
+}
#endif
+static inline struct fwnode_handle *
+device_dpll_pin_node_get(struct device *dev, const char *name)
+{
+ return fwnode_dpll_pin_node_get(dev_fwnode(dev), name);
+}
+
struct dpll_device *
dpll_device_get(u64 clock_id, u32 dev_driver_id, struct module *module);
--
2.52.0
next prev parent reply other threads:[~2026-01-16 18:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 18:45 [PATCH net-next v2 00/12] dpll: Core improvements and ice E825-C SyncE support Ivan Vecera
2026-01-16 18:45 ` [PATCH net-next v2 01/12] dt-bindings: dpll: support acting as pin provider Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 02/12] dpll: Allow associating dpll pin with a firmware node Ivan Vecera
2026-01-16 18:46 ` Ivan Vecera [this message]
2026-02-08 1:46 ` [PATCH net-next v2 03/12] dpll: Add helpers to find DPLL pin fwnode Saravana Kannan
2026-02-10 7:19 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-16 18:46 ` [PATCH net-next v2 04/12] dpll: zl3073x: Associate pin with fwnode handle Ivan Vecera
2026-01-19 7:49 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-16 18:46 ` [PATCH net-next v2 05/12] dpll: Add notifier chain for dpll events Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 06/12] dpll: Support dynamic pin index allocation Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 07/12] dpll: zl3073x: Add support for mux pin type Ivan Vecera
2026-01-19 7:50 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-16 18:46 ` [PATCH net-next v2 08/12] dpll: Enhance and consolidate reference counting logic Ivan Vecera
2026-01-21 0:16 ` [net-next,v2,08/12] " Jakub Kicinski
2026-01-21 8:18 ` Ivan Vecera
2026-01-23 14:58 ` Simon Horman
2026-01-23 15:27 ` Ivan Vecera
2026-01-23 18:04 ` Simon Horman
2026-01-16 18:46 ` [PATCH net-next v2 09/12] dpll: Prevent duplicate registrations Ivan Vecera
2026-01-19 7:50 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-16 18:46 ` [PATCH net-next v2 10/12] dpll: Add reference count tracking support Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 11/12] drivers: Add support for DPLL reference count tracking Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 12/12] ice: dpll: Support E825-C SyncE and dynamic pin discovery Ivan Vecera
2026-01-21 0:18 ` [net-next,v2,12/12] " Jakub Kicinski
2026-01-21 14:20 ` Nitka, Grzegorz
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=20260116184610.147591-4-ivecera@redhat.com \
--to=ivecera@redhat.com \
--cc=Prathosh.Satish@microchip.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=grzegorz.nitka@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jiri@resnulli.us \
--cc=jonathan.lemon@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=saeedm@nvidia.com \
--cc=saravanak@kernel.org \
--cc=tariqt@nvidia.com \
--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