Patchwork [U-Boot,2/6] fm-eth: add function fm_info_get_phy_address()

login
register
mail settings
Submitter Timur Tabi
Date Aug. 10, 2012, 10:01 p.m.
Message ID <1344636096-11669-2-git-send-email-timur@freescale.com>
Download mbox | patch
Permalink /patch/176633/
State Superseded
Headers show

Comments

Timur Tabi - Aug. 10, 2012, 10:01 p.m.
Function fm_info_get_phy_address() returns the PHY address for a given
Fman port.  This is handy when the MDIO code needs to fixup the Ethernet
nodes in the device tree to point to PHY nodes for a specific PHY address.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 drivers/net/fm/init.c |   16 ++++++++++++++++
 include/fm_eth.h      |    1 +
 2 files changed, 17 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/net/fm/init.c b/drivers/net/fm/init.c
index 9834cd9..8a5311c 100644
--- a/drivers/net/fm/init.c
+++ b/drivers/net/fm/init.c
@@ -155,6 +155,22 @@  void fm_info_set_phy_address(enum fm_port port, int address)
 }
 
 /*
+ * Returns the PHY address for a given Fman port
+ *
+ * The port must be set via a prior call to fm_info_set_phy_address().
+ * A negative error code is returned if the port is invalid.
+ */
+int fm_info_get_phy_address(enum fm_port port)
+{
+	int i = fm_port_to_index(port);
+
+	if (i == -1)
+		return -1;
+
+	return fm_info[i].phy_addr;
+}
+
+/*
  * Returns the type of the data interface between the given MAC and its PHY.
  * This is typically determined by the RCW.
  */
diff --git a/include/fm_eth.h b/include/fm_eth.h
index 05121ea..e56541d 100644
--- a/include/fm_eth.h
+++ b/include/fm_eth.h
@@ -110,6 +110,7 @@  void fman_enet_init(void);
 void fdt_fixup_fman_ethernet(void *fdt);
 phy_interface_t fm_info_get_enet_if(enum fm_port port);
 void fm_info_set_phy_address(enum fm_port port, int address);
+int fm_info_get_phy_address(enum fm_port port);
 void fm_info_set_mdio(enum fm_port port, struct mii_dev *bus);
 void fm_disable_port(enum fm_port port);