[PATCH 1/3] Add fdt network helper header file

Tony Dinh mibodhi at gmail.com
Fri Aug 6 06:49:08 CEST 2021


Add include header file include/fdt_support_net.h

Signed-off-by: Tony Dinh <mibodhi at gmail.com>
---

 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..4fe447f803
--- /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 -1 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