[PATCH v2 2/3] common: Add fdt network helper header file

Tony Dinh mibodhi at gmail.com
Sun Aug 15 02:17:12 CEST 2021


Add include header file fdt_support_net.h

Reviewed-by: Stefan Roese <sr at denx.de>
Acked-by: Ramon Fried <rfried.dev at gmail.com>
Signed-off-by: Tony Dinh <mibodhi at gmail.com>
---

Changes in v2:
- Return FDT_ERR_NOTFOUND if fdt_get_phy_addr failed to find PHY addr

 include/fdt_support_net.h | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 include/fdt_support_net.h

diff --git a/include/fdt_support_net.h b/include/fdt_support_net.h
new file mode 100644
index 0000000000..87852ffc41
--- /dev/null
+++ b/include/fdt_support_net.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Copyright (C) 2021 Tony Dinh <mibodhi at gmail.com>
+ */
+
+#ifndef __fdt_support_net_h
+#define __fdt_support_net_h
+
+/**
+ * This file contains convenience functions for decoding network related
+ * information from FDTs. It is intended to be used by board-specific code
+ * within U-Boot.
+ */
+
+/*
+ * fdt_get_phy_addr - Return the Ethernet PHY address
+ *
+ * Convenience function to return the PHY address of an
+ * ethernet device given its full path as defined in the device tree
+ *
+ * @path	full path to the network device node
+ * @return	PHY address, or -FDT_ERR_NOTFOUND if it does not exist
+ *
+ * Usage examples:
+ *
+ * Get PHY address of eth0 for a Kirkwood board as defined in kirkwood.dtsi
+ *	int phyaddr;
+ *	char *eth0_path = "/ocp at f1000000/ethernet-controller at 72000";
+ *	phyaddr = fdt_get_phy_addr(eth0_path);
+ *
+ * Get PHY address of eth1 for a Armada 38x board as defined
+ * in armada-38x.dtsi
+ *	int phyaddr;
+ *	char *eth1_path = "/soc/ethernet at 30000";
+ *	phyaddr = fdt_get_phy_addr(eth1_path);
+ */
+int fdt_get_phy_addr(const char *path);
+
+#endif
-- 
2.20.1



More information about the U-Boot mailing list